Date format is not changed for Forms module's form's date field

I have made some forms with date fields and selected the d-m-Y format for date but its not changed when the form is rendered on page and still is m/d/Y format due to which I can't validate it with jquery.validate. I have tried looking into guide and found that we can change it in My_config and My_fuel files, but that has no effect. I want the dates to be formatted in d-m-Y. Anyway I can achieve this?

Comments

  • I think so too, because after I posted this question I tried with MY_config file and it seem to work now, thanks

  • Hey can you put another format 'd/m/Y' or is that too much to ask? As I can't use d-m-Y with jquery.validator

  • d/m/Y is problematic because it's not supported by PHP's strtotime function which is used on the backend to translate dates.

  • okay can you tell me how jquery.validator works by default for fuel because I have a form with date fields and I can't validate them as the jquery seems to be checking for two formats at once, by default it checks for mm/dd/yyyy format and I have enabled dateITA so it also checks for dd/mm/yyyy format, as in my date field I can't put any value greater than 12 in both places (dd and mm).

  • Are you saying you are getting a validation error or you simply aren't allowed to enter in those values and it's restricting you? The datepicker field uses the fuel.fields.datetime_field function found in the fuel/modules/fuel/assets/js/fuel/custom_fields.js file.

  • I am getting a validation error upon entering the dates in aformentioned formats. I had posted the question on stackoverflow and it seems that because I am using Forms module to create date fields, the class date is causing the issue. So how can I replace the date class as it is generated when calling the form helper method?

  • The date field type is actually just a text box with that class associated with it that the javascript looks for. You could mimic that behavior by creating a text field with your own class that uses javascript to instantiate the behavior you want. To add additional javascript to your forms, see this area in the docs:
    http://docs.getfuelcms.com/general/javascript

  • Well, yes but I am using the forms module and thus creating form from there and using it in page, could I still manipulate the fields without controller? For now I have used jquery to remove date class and the validation works now.

  • You can access the form object by using something like the following:

    $form = $CI->fuel->forms->get('my_form');
    $form->add_field('my_field', [....]);
    

    To overwrite an existing field, pass in the same name as the field you want to overwrite.

Sign In or Register to comment.