5537 Posts in 1737 Topics by 1223 members
|Go to End|
3 August 2010 at 3:39am Last edited: 3 August 2010 4:50am
I'm having trouble setting the date format to en_GB (dd-mm-yyyy) format when using a UserDefinedForm page.
In mysite/_config.php, I set the i18n config to my locale which seems to work elsewhere on the site, just not here. The DatePicker field inserts an en_US formatted date, and when submitted, the CMS validates it against en_GB so I'm pretty sure it's just down to the DatePicker.
I'm using 2.4.1
3 August 2010 at 6:39pm
The locale is hard coded in the UDF file. The files which you will need to edit are the EditableDateField.php file. getFormField() returns the datepicker so that needs to be passed the correct format using dateFormat (http://jqueryui.com/demos/datepicker/).
I have created a ticket for this work - http://open.silverstripe.org/ticket/5902.
3 August 2010 at 9:02pm Last edited: 3 August 2010 9:22pm
I've updated EditableDateField.php to specify jQuery UI's dateFormat when datepicker is called on the element. For now I'm using i18n::get_date_format().
Use the file below if you like, hope it helps others.
3 August 2010 at 9:12pm
Sweet does that work? If it does attach that file up on the ticket and I can integrate it. I think that would be useful. I thought about having the format in the CMS but that seems a very edge case.
3 August 2010 at 9:28pm Last edited: 3 August 2010 9:28pm
Yep it works. I've upped the file on trac.
In the meantime I'm just overriding it with a custom form field in mysite/code/fields/
|Go to Top|