Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I added a "Birth date" field to the user entity. It uses the "Pop-up calendar" widget and has Starting year set to -100 and Ending year set to -14.
The popup correctly shows a drop-down list with years ranging from 1912 to 1998 but nothing prevents the user from manually typing and saving a date such as "08/05/2012".
I think the date_popup module should verify the year range? I've attached a patch which works for me but I'm not sure if it's the best solution.
Comment | File | Size | Author |
---|---|---|---|
date_popup_validate_date_range.patch | 533 bytes | joericapens | |
Comments
Comment #1
Paul B CreditAttribution: Paul B commentedIf the date is outside the range, the date/time is not converted to a string (done in date_popup_validate I believe).
If you have a form validation function that checks the date, it will suddenly see an array instead of a string for the date.
Comment #2
Paul B CreditAttribution: Paul B commentedAlso, this only adds validation to the date_popup, not to the date_text. I think both widgets should have validation, so both should have a year range setting.
Comment #3
Paul B CreditAttribution: Paul B commentedDuplicate of #88021: Support maximum and minimum values for dates