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)

7664.diff (3.7 KB ) - added by Koen Biermans 13 years ago.
patch to allow passing names for widgets into MultiWidget

Download all attachments as: .zip

Change History (13)

comment:1 by Matt McClanahan, 16 years ago

Component: Uncategorizeddjango.newforms
Keywords: multiwidget added
Triage Stage: UnreviewedDesign decision needed

comment:2 by Luke Plant, 14 years ago

Severity: Normal
Type: New feature

comment:3 by Jacob, 13 years ago

Easy pickings: unset
Triage Stage: Design decision neededAccepted
UI/UX: unset

Yes, this is a good idea.

by Koen Biermans, 13 years ago

Attachment: 7664.diff added

patch to allow passing names for widgets into MultiWidget

comment:4 by Koen Biermans, 13 years ago

Has patch: set
Needs documentation: set

Added a small patch which allows passing names into MultiWidget as suggested.

comment:5 by anonymous, 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 David Smith, 5 years ago

Needs documentation: unset
Owner: changed from nobody to David Smith
Status: newassigned
Version 0, edited 5 years ago by David Smith (next)

comment:7 by Simon Charette, 5 years ago

Patch needs improvement: set

comment:8 by David Smith, 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 Mariusz Felisiak, 5 years ago

Needs documentation: set
Patch needs improvement: set

comment:10 by David Smith, 5 years ago

Needs documentation: unset
Patch needs improvement: unset

comment:11 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:12 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 27746ab2:

Fixed #7664 -- Allowed customizing suffixes of MultiWidget.widgets' names.

Note: See TracTickets for help on using tickets.
Back to Top