Extend Form Date Field Range to allow for Birth Date selection
Permalink
The Date field in the core form appears to only allow for +-10 years when selecting a date. For instance, it won't let you select a year prior to 2004 or a year after 2024. I need this field to allow for people to choose their birth date/year and it should go back to 1920 maybe? Any thoughts?
I'll give it a shot and report back.. thanks. It is 5.6.3.1 in case it doesn't work.
*You are supposed to override the helper so as not to interfere with the core and overriding the helper is a little different than overriding most files so I will try to update this with that info soon as I am not quite sure why my attempts to do that have not worked out so far, hopefully this helps for now.
For 5.6.3 at line 153 replace this
with this
and same at 210, replace this
with this
Additional info for those with similar needs.
"c-100:c+0" represents 100 years ago to present day. Back a 100 years, forward 0 years. Example of 50 years ago to 50 years in the future would be "c-50:+50"
If one wanted to limit a range of years say 1920 to 1930 you would instead put "1920:1930" instead of "c-:+"
put to practice you would change line 153 to
and 210 to
Text file attached of -100 years for reference just in case. (rename date_time.php if uploading)
For 5.6.3 at line 153 replace this
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '_dt").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\' }); });</script>';
with this
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\', yearRange: "c-100:c+0" }); });</script>';
and same at 210, replace this
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\' }); });</script>';
with this
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\', yearRange: "c-100:c+0" }); });</script>';
Additional info for those with similar needs.
"c-100:c+0" represents 100 years ago to present day. Back a 100 years, forward 0 years. Example of 50 years ago to 50 years in the future would be "c-50:+50"
If one wanted to limit a range of years say 1920 to 1930 you would instead put "1920:1930" instead of "c-:+"
put to practice you would change line 153 to
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '_dt").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\', yearRange: "1920:1930" }); });</script>';
and 210 to
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\', yearRange: "1920:1930" }); });</script>';
Text file attached of -100 years for reference just in case. (rename date_time.php if uploading)
Beautiful... works great. I assume your mentioning the helpers overriding issue is why when I place a forms/date_time.php file with modifications in the Root I get an error? I dropped it into the core helpers directory and it works great! Thanks for the help... did a c-100:c+10 just in case it messed with the date picker for ALL of the website and I want other forms to be able to select future dates.
Thanks again!
James
Thanks again!
James
If I remember right I was adding Site to the class and from there failed a lil further. Glad things worked out in the end though :)
http://www.concrete5.org/community/forums/customizing_c5/date-picke...
Same issue with a solution and decently recent. If it doesn't help can you post which version of concrete5 that you are using, ex 5.6.3.1.