Thursday, June 27, 2019

Why does SelectDateWidget ignore empty_label when field is required?

Greetings,

I have a ModelForm with a required date field that I am using SelectDateWidget with. I would like to default the select fields to empty placeholder values and force the user to pick a specific date, rather than defaulting to the first possible one. However when I pass empty_label to the widget the values are ignored, since the field is required. I could probably sub-class SelectDateWidget and change it to get the behavior I'm looking for, but after looking at the code and documentation it's clear that the current behavior is a deliberate choice. My question is: Why are placeholders ignored when the date field is required?

My use case doesn't seem that unusual so I'm guessing there's a strong reason why it's not supported. I'd love to know what that reason is before I go making a mess of things. Any help is much appreciated.

Thanks,

Aaron

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/45527443-3dcf-4b4e-a66e-5e6aef426de1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment