Search code examples
contao

How to accept German date format in Contao 4 widget?


I'm working with Contao 4 and have a widget with the following configuration in the eval sub array:

'eval' => array(
    'class' => 'valid_date',
    'rgxp' => 'date',
    'dateformat' => 'd.m.Y',
    'datepicker' => TRUE,
    'tl_class' => 'w50 wizard',
    'maxlength' => 255,
    'mandatory' => TRUE
),

The default 'date' validation expects the format to be in YYYY-MM-DD, but I need to accept the German date format (d.m.Y).

I have tried the following:

'dateformat' => 'd.m.Y',
'datepickerFormat' => 'd.m.Y',

Is there a built-in solution or an alternative approach to handle the German date format without creating a custom filter module?

Is maybe something wrong with the current locale? Would Contao detect the current locale?

But the frontend is displayed in German and even the error message is in German.


Solution

  • I was looking at the wrong place.

    The date format is configured at System -> Settings. If I change that, it works.