Opened 16 years ago
Closed 5 years ago
#7664 closed New feature (fixed)
MultiWidget to support named sub widgets
Reported by: | Collin Anderson | Owned by: | David Smith |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | multiwidget |
Cc: | cmawebsite@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
It would be nice if MultiWidget would support names for its sub widgets.
Currently if
widgets = (TextInput(attrs=attrs), TextInput(attrs=attrs))
you get something like this:
<input type="text" name="name_0"><input type="text" name="name_1">
Which is a bit ugly.
I would like to see something like one of these:
widgets = (TextInput(attrs=attrs), TextInput(attrs=attrs)) names = ('date', 'time')
or
widgets = (('date', TextInput(attrs=attrs)), ('time', TextInput(attrs=attrs)))
These would render to something like this:
<input type="text" name="name_date"><input type="text" name="name_time">
Attachments (1)
Change History (13)
comment:1 by , 16 years ago
Component: | Uncategorized → django.newforms |
---|---|
Keywords: | multiwidget added |
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:3 by , 13 years ago
Easy pickings: | unset |
---|---|
Triage Stage: | Design decision needed → Accepted |
UI/UX: | unset |
by , 13 years ago
patch to allow passing names for widgets into MultiWidget
comment:4 by , 13 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
Added a small patch which allows passing names into MultiWidget as suggested.
comment:5 by , 11 years ago
Please also add the ability to override the _
separator. Creating a multiwidget for autocompletion ends up making field_1
and field_2
in POST when I'd really like to be able to generate field
and field_text
, because keeping field
will make sure using the widget doesn't break any tests that use POSTdata. There are workarounds, but I feel like it's not something so complicated it deserves its own hack.
comment:6 by , 5 years ago
Needs documentation: | unset |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:7 by , 5 years ago
Patch needs improvement: | set |
---|
comment:8 by , 5 years ago
Patch needs improvement: | unset |
---|
I've made improvements to this based on feedback on the PR. Please can this be reviewed again.
comment:9 by , 5 years ago
Needs documentation: | set |
---|---|
Patch needs improvement: | set |
comment:10 by , 5 years ago
Needs documentation: | unset |
---|---|
Patch needs improvement: | unset |
comment:11 by , 5 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Yes, this is a good idea.