Jump to:

5514 Posts in 1733 Topics by 1219 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Localising Date Picker Fields in UserDefinedForm

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1632 Views
  • avengex
    Avatar
    Community Member
    11 Posts

    Localising Date Picker Fields in UserDefinedForm Link to this post

    Hi,

    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

    Any ideas?

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Localising Date Picker Fields in UserDefinedForm Link to this post

    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.

  • avengex
    Avatar
    Community Member
    11 Posts

    Re: Localising Date Picker Fields in UserDefinedForm Link to this post

    Cheers Will..

    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.

    Attached Files
  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Localising Date Picker Fields in UserDefinedForm Link to this post

    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.

  • avengex
    Avatar
    Community Member
    11 Posts

    Re: Localising Date Picker Fields in UserDefinedForm Link to this post

    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/

    1632 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.