form/date_time helper datepicker dateformat issue
Permalink 2 users found helpful
There is an issue with the core C5 form/date_time.php helper in that when it creates a JQuery datepicker it doesn't pass the dateFormat to match the C5 format set in site.php. I think this is something that requires a core fix as helpers cannot be overridden (yet).
What I did was change my core date_time.php helper
This is obviously only a temp site by site solution as it's hardcoded and in a core file. My issue came up using the Extended form addon and in theiry a fix could be sorted in that but really this is a core helper issue.
Ideally either the helper should be altered to cope with this need or the $.datepicker.setDefaults() should be used elsewhere preferably where it can be overridden.
I'd suggest the DATE_APP_GENERIC_MDY gets used to set this but it'll have to be parsed to get the right JQuery formatting as it's different from php.
Anyway in the meantime maybe this will be useful for anyone having the same issue.
If there is another easier way of sorting this I'd appreciate being told.
Regards,
Steve.
What I did was change my core date_time.php helper
public function datetime($prefix, $value = null, $includeActivation = false, $calendarAutoStart = true) { ... if ($calendarAutoStart) { $html .= '<script type="text/javascript">$(function() { $("#' . $id . '_dt").datepicker({ changeYear: true, showAnim: \'fadeIn\', dateFormat: \'dd/mm/yy\'}); });</script>'; } ... return $html; }
This is obviously only a temp site by site solution as it's hardcoded and in a core file. My issue came up using the Extended form addon and in theiry a fix could be sorted in that but really this is a core helper issue.
Ideally either the helper should be altered to cope with this need or the $.datepicker.setDefaults() should be used elsewhere preferably where it can be overridden.
I'd suggest the DATE_APP_GENERIC_MDY gets used to set this but it'll have to be parsed to get the right JQuery formatting as it's different from php.
Anyway in the meantime maybe this will be useful for anyone having the same issue.
If there is another easier way of sorting this I'd appreciate being told.
Regards,
Steve.
thanks a lot. exactly what I was looking for.
You're welcome!
Very handy post - couldn't understand why date format was not being picked up.
Thanks for this post - it saved me some time.
Thanks for this post - it saved me some time.