diff --git a/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module b/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module index 092e6f6..b5b7354 100644 --- a/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module +++ b/web/modules/custom/figli_compta_ledger/figli_compta_ledger.module @@ -37,6 +37,22 @@ function figli_compta_ledger_form_alter(&$form, FormStateInterface $form_state, } $form['#validate'][] = 'figli_compta_ledger_validate_repartition'; + // The default date widget renders as a native , + // whose displayed digit order (07/26/2024 vs 26/07/2024) follows the + // browser's own locale setting -- not anything Drupal or this site's + // language controls, so an English-locale browser shows the American + // mm/dd/yyyy order no matter what. Switching the date sub-element from + // 'date' (native picker) to 'text' with an explicit PHP date format + // makes Drupal itself own the display/parsing, so it's the same + // jj/mm/aaaa for everyone regardless of browser locale. Trade-off: + // loses the native calendar picker (Drupal core ships no JS date- + // picker to pair with the text variant) -- acceptable here, dates are + // typically typed directly for this kind of data entry. + if (isset($form['field_date_ligne']['widget'][0]['value'])) { + $form['field_date_ligne']['widget'][0]['value']['#date_date_element'] = 'text'; + $form['field_date_ligne']['widget'][0]['value']['#date_date_format'] = 'd/m/Y'; + } + // Every save must create a revision, unconditionally -- there's no // legitimate reason to skip it for an accounting record, so don't let // anyone opt out. #access = FALSE (rather than just leaving the