Opened 11 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 Daniel Samuels, 11 years ago

Cc: Daniel Samuels added

comment:2 by Claude Paroz, 11 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

comment:3 by Guillaume Pannatier, 11 years ago

Owner: changed from nobody to Guillaume Pannatier
Status: newassigned

comment:4 by Guillaume Pannatier, 11 years ago

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

comment:5 by Guillaume Pannatier, 11 years ago

Has patch: set

comment:6 by Claude Paroz, 11 years ago

Version: 1.6master

I left some comments on the PR. This will only be considered for 1.8, as 1.7 is already feature-frozen.

comment:7 by Guillaume Pannatier, 11 years ago

Thanks for your comments on the PR.
I make needed changes.

Version 0, edited 11 years ago by Guillaume Pannatier (next)

comment:8 by Claude Paroz, 11 years ago

Needs documentation: set

comment:9 by Guillaume Pannatier, 11 years ago

I have change the documentation with this new feature.

comment:10 by Claude Paroz, 11 years ago

@danielsamuels: does the proposed implementation fulfill your use case?

comment:11 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 32586b0ba43816d325be0ce807f75623683eed7a:

Fixed #22684 -- Added empty_label option on django.forms.extras.widets.SelectDateWidget

Thanks danielsamuels for the report

comment:12 by Daniel Samuels, 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 Tim Graham, 10 years ago

Resolution: fixed
Status: closednew

Or maybe change empty_label -> empty_labels and make it a 3-tuple corresponding to year/month/day?

comment:14 by Guillaume Pannatier, 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 Guillaume Pannatier, 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:16 by Guillaume Pannatier, 10 years ago

Status: newassigned

The new PR for review and remarks

https://github.com/django/django/pull/2737

comment:17 by Daniel Samuels, 10 years ago

That makes a lot more sense, thanks for putting the work in gyx1000.

comment:18 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 7e2c87809ca601b7290203dd54ba3e9f90a702bd:

Fixed #22684 -- Amended SelectDateWidget.empty_label to accept a tuple of values.

Thanks danielsamuels for the report

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