﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17683	`BaseModelFormSet` ignore form's widgets options when adding the pk field	Simon Charette	Simon Charette	"When defining a custom widget for the pk field of a modelform used in a modelformset this way:

{{{
#!python
class MyModelForm(forms.ModelForm):
    class Meta:
        model = MyModel
        widgets = {
          'id': forms.HiddenInput(attrs={'class': 'a-useful-class'})
        }

MyFormSet = modelformset_factory(MyModel, MyModelForm)
}}}

The specified widget is ignored because of [https://github.com/django/django/blob/master/django/forms/models.py#L661 this line].

It should be replaced by something along
{{{
#!python
widget = form._meta.widgets.get(self._pk_field.name, HiddenInput)
form.fields[self._pk_field.name] = ModelChoiceField(qs, initial=pk_value, required=False, widget=widget)
}}}

I'll provide patch with tests if this gets accepted.
"	Bug	closed	Forms	dev	Normal	fixed	basemodelformset widget	charette.s@…	Ready for checkin	1	0	0	0	1	0
