Opened 2 months ago
formset prefix attribute and formset empty form "__prefix__" don't refer to the same thing
|Reported by:||bjb@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:|
|Needs tests:||Patch needs improvement:|
The formset prefix attribute and formset emptyform "__prefix__" placeholder don't refer to the same thing
Formsets allow you to change the word "form" in the ids of the elements in the form to some other string, and the way you do that is with the "prefix" kwarg when creating the FormsetFactory. eg, id_form-5_id -> id_note-5_id when prefix = note. That's good.
Unfortunately, the placeholder for the form number in the ids of the empty form elements is called __prefix__. That is confusing, because the prefix passed in to the formset is used in the ids in a different spot.
id_note-__prefix__-id, where "note" was passed in as the value for the prefix kwarg.
I think the __prefix__ placeholder should be changed to some other string, like "formnum".
An emptyform with no prefix specified would then look like: id_form-__formnum__-id