Opened 10 years ago
Closed 10 years ago
#22684 closed New feature (fixed)
SelectDateWidget's none_value is not changeable
Reported by: | Daniel Samuels | Owned by: | Guillaume Pannatier |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Daniel Samuels | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | yes |
Description
If you want to use a SelectDateWidget to represent your DateField, your output will have "---" as the default option text, this text is not changeable to suit the needs of each individual application in the same way that other fields can have their default set. I believe this widget should gain a new attribute such as empty_label
to match standard ChoiceFields.
Change History (18)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 10 years ago
comment:5 by , 10 years ago
Has patch: | set |
---|
comment:6 by , 10 years ago
Version: | 1.6 → master |
---|
I left some comments on the PR. This will only be considered for 1.8, as 1.7 is already feature-frozen.
comment:8 by , 10 years ago
Needs documentation: | set |
---|
Great, now only the docs are missing.
https://docs.djangoproject.com/en/dev/ref/forms/widgets/#selectdatewidget
comment:10 by , 10 years ago
@danielsamuels: does the proposed implementation fulfill your use case?
comment:11 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:12 by , 10 years ago
Apologies for the slow reply, seems as though being CC'd doesn't actually send emails. As far as I can see, this isn't providing the option to change the empty_label for each field individually. The widget provides 3 <select> fields, one for day, one for month and one for year, the pull request appears to be setting the empty value for all 3 at the same time. What I would like to be able to achieve is to have 'Day' as the default value for the Day dropdown, 'Month' as the default for the month dropdown and 'Year' as the default for the year dropdown. I'm not entirely sure what an appropriate default value could even be used with this pull request, as it would need to be relevant for all 3 dropdowns, which doesn't really seem very flexible.
My proposal would be to have 3 kwargs in place of the current 1, something along the lines of day_empty_label
, month_empty_label
and year_empty_label
, this would give all of the flexibility required.
comment:13 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
Or maybe change empty_label
-> empty_labels
and make it a 3-tuple corresponding to year/month/day?
comment:14 by , 10 years ago
For me, change the empty_label to empty_labels (3-tuple) seams to be a good idea.
What do you think @danielsamuels ?
comment:15 by , 10 years ago
We can also keep empty_label and accept a string or a 3-tuple ?
If a string is passed, all select will have the same empty_value otherwise, select will have corresponding values.
comment:18 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
PR available for review at:
https://github.com/django/django/pull/2704
Thanks
PS : I need help for change documentation
Because this new feature is assigned to version 1.6. I don't know how add
informations for this feature in docs/ref/forms/widgets.txt