Opened 9 years ago

Last modified 3 months ago

#5851 new New feature

SplitDateTimeWidget (or MultiWidget) doesn't allow different attrs for different fields

Reported by: ciantic@… Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords: SplitDateTimeWidget MultiWidget
Cc: cmawebsite@…, kmike84@…, charette.s@…, james.kirsop@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Many times it is needed to have for instance different class attribute value for DateField than TimeField, therefore SplitDateTimeWidget should have a way to give different attrs for time and datefields.
(e.g. Javascript helpers, one with contrib.admin is good example)

There are two ways to fix the problem:
1.) add the possiblity to MultiWidget and let SplitDateTimeWidget merely use the ability or,
2.) add the possiblity to SplitDateTimeWidget

First method is semantically a bit more correct, but requires more than few seconds of implementation (Currently I'm out of time and I can't spare to implement patch for first approach).

Here is the patch for second approach (note that for the second approach leaving the multiwidget attrs as None was sufficient)

Attachments (2)

widgets_2.diff (727 bytes) - added by ciantic@… 9 years ago.
Second approach to the problem
5851.diff (4.7 KB) - added by Koen Biermans 5 years ago.
patch allow list of attrs into multiwidget

Download all attachments as: .zip

Change History (15)

Changed 9 years ago by ciantic@…

Attachment: widgets_2.diff added

Second approach to the problem

comment:1 Changed 9 years ago by anonymous

Component: Core frameworkdjango.newforms

comment:2 Changed 9 years ago by MichaelBishop

Triage Stage: UnreviewedDesign decision needed

Appears to be a design decision based on the options presented in the description.

If the first approach is chosen, then a patch is required. If the second approach is chosen, then the patch needs to be evaluated.

comment:3 Changed 8 years ago by Collin Anderson

Cc: cmawebsite@… added

Is this a duplicate of #4117?

comment:4 Changed 6 years ago by Gabriel Hurley

Severity: Normal
Type: New feature

comment:5 Changed 5 years ago by Jacob

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

The first solution (making the fix to MultiWidget) is the right way to go.

comment:6 Changed 5 years ago by Julien Phalip

#14718 was closed as duplicate. See also #16754 for a related issue.

comment:7 Changed 5 years ago by Julien Phalip

#10343 was also closed as dupe.

comment:8 Changed 5 years ago by Jacob

And other: #16754.

comment:9 Changed 5 years ago by Mikhail Korobov

Cc: kmike84@… added
Needs tests: set
Patch needs improvement: set

Changed 5 years ago by Koen Biermans

Attachment: 5851.diff added

patch allow list of attrs into multiwidget

comment:10 Changed 5 years ago by Koen Biermans

Needs documentation: set
Needs tests: unset
Patch needs improvement: unset

Attaching a patch that allows passing a list of attrs into the multiwidget (first approach).

Includes some simple tests.

No documentation yet.

comment:11 Changed 4 years ago by Simon Charette

Cc: charette.s@… added

comment:12 Changed 3 months ago by James Kirsop

Cc: james.kirsop@… added

Would love to see this reviewed at some stage. It would be particularly helpful in supporting the "placeholder" attribute.

comment:13 Changed 3 months ago by Claude Paroz

Before this is reviewed, we should have a pull request with the proposed patch, including tests and docs.

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