Opened 17 years ago
Closed 8 years ago
#5851 closed New feature (fixed)
SplitDateTimeWidget (or MultiWidget) doesn't allow different attrs for different fields
Reported by: | Owned by: | Mariusz Felisiak | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | SplitDateTimeWidget MultiWidget |
Cc: | cmawebsite@…, kmike84@…, charette.s@…, james.kirsop@…, felisiak.mariusz@… | 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
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)
Change History (20)
by , 17 years ago
Attachment: | widgets_2.diff added |
---|
comment:1 by , 17 years ago
Component: | Core framework → django.newforms |
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → 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:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:5 by , 13 years ago
Easy pickings: | unset |
---|---|
Triage Stage: | Design decision needed → Accepted |
UI/UX: | unset |
The first solution (making the fix to MultiWidget
) is the right way to go.
comment:9 by , 13 years ago
Cc: | added |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
comment:10 by , 13 years ago
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 by , 12 years ago
Cc: | added |
---|
comment:12 by , 8 years ago
Cc: | added |
---|
Would love to see this reviewed at some stage. It would be particularly helpful in supporting the "placeholder" attribute.
comment:13 by , 8 years ago
Before this is reviewed, we should have a pull request with the proposed patch, including tests and docs.
comment:14 by , 8 years ago
Cc: | added |
---|---|
Needs documentation: | unset |
Owner: | changed from | to
Status: | new → assigned |
I think that this is a issue specific for SplitDateTimeWidget
and SplitHiddenDateTimeWidget
, because in general you can get the same result in a different way e.g.:
MultiWidget( widgets=( Input(attrs={'class': 'foo'}), Input(attrs={'class': 'bar'}), ) )
IMO there is no need to complicate MultiWidget
.
comment:15 by , 8 years ago
Patch needs improvement: | set |
---|
comment:16 by , 8 years ago
Patch needs improvement: | unset |
---|
comment:17 by , 8 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Second approach to the problem