[Django] #21743: formset prefix attribute and formset empty form "__prefix__" don't refer to the same thing

17 views
Skip to first unread message

Django

unread,
Jan 7, 2014, 10:42:03 PM1/7/14
to django-...@googlegroups.com
#21743: formset prefix attribute and formset empty form "__prefix__" don't refer to
the same thing
--------------------------------------+----------------------------
Reporter: bjb@… | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Forms | Version: 1.6
Severity: Normal | Keywords: formset prefix
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+----------------------------
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.

Formsets have a way to generate an empty form so you can add new forms
into your html with simple javascript, you don't have to know what all the
fields are in javascript - just clone the empty form (and adjust the ids
and fix up the TOTAL_FORMS etc). 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`

--
Ticket URL: <https://code.djangoproject.com/ticket/21743>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 29, 2014, 7:23:52 AM4/29/14
to django-...@googlegroups.com
#21743: formset prefix attribute and formset empty form "__prefix__" don't refer to
the same thing
-------------------------------------+-------------------------------------
Reporter: bjb@… | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: 1.6
Component: Forms | Resolution: wontfix
Severity: Normal | Triage Stage:
Keywords: formset prefix | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

* status: new => closed
* needs_better_patch: => 0
* resolution: => wontfix
* needs_tests: => 0
* needs_docs: => 0


Comment:

The inconsistency is too bad, but I don't think we can make the change
without breaking backwards compatibility. If I'm missing something, feel
free to reopen.

--
Ticket URL: <https://code.djangoproject.com/ticket/21743#comment:1>

Reply all
Reply to author
Forward
0 new messages