Opened 8 years ago

Last modified 2 years 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@… 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@… 8 years ago.
Second approach to the problem
5851.diff (4.7 KB) - added by koenb 3 years ago.
patch allow list of attrs into multiwidget

Download all attachments as: .zip

Change History (13)

Changed 8 years ago by ciantic@…

Second approach to the problem

comment:1 Changed 8 years ago by anonymous

  • Component changed from Core framework to django.newforms
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by MichaelBishop

  • Triage Stage changed from Unreviewed to Design 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 7 years ago by CollinAnderson

  • Cc cmawebsite@… added

Is this a duplicate of #4117?

comment:4 Changed 4 years ago by gabrielhurley

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 4 years ago by jacob

  • Easy pickings unset
  • Triage Stage changed from Design decision needed to Accepted
  • UI/UX unset

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

comment:6 Changed 4 years ago by julien

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

comment:7 Changed 4 years ago by julien

#10343 was also closed as dupe.

comment:8 Changed 4 years ago by jacob

And other: #16754.

comment:9 Changed 4 years ago by kmike

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

Changed 3 years ago by koenb

patch allow list of attrs into multiwidget

comment:10 Changed 3 years ago by koenb

  • 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 2 years ago by charettes

  • Cc charette.s@… added
Note: See TracTickets for help on using tickets.
Back to Top