I use the Form API to build forms in custom module.
Forms works fine but my custom date format is not applied.
Here is an extract of my form code :
$form['date_debut'] = array(
'#type' => 'date',
'#title' => $this->t('Date de début'),
'#date_date_format' => 'd/m/Y',
'#description' => t('Cliquez dans le champ et sélectionnez une date de début de congé dans le calendrier'),
'#required' => TRUE
);
The date format is d/m/Y
But i still see Y/m/d
in the input :
In the DOM, the date format is d/m/Y data-drupal-date-format="d/m/Y"
<input type="text" data-drupal-selector="edit-date-fin" aria-describedby="edit-date-fin--description" data-drupal-date-format="d/m/Y" class="form-date required form-control hasDatepicker" id="edit-date-fin" name="date_fin" value="" required="required" aria-required="true">
When the form is validated, i display a message with the date picker value and the date format is Y/m/d
drupal_set_message($this->t('Vous avez choisi comme date de début : @date_debut', array('@date_debut' => $form_state->getValue('date_debut'))));
See :
Am i missing something? How can i modify this date format visible by the user in the input and in the Drupal message ?