diff --git a/app/src/View/Helper/FieldHelper.php b/app/src/View/Helper/FieldHelper.php index b96c34afb..8ed937619 100644 --- a/app/src/View/Helper/FieldHelper.php +++ b/app/src/View/Helper/FieldHelper.php @@ -106,7 +106,7 @@ public function control(string $fieldName, // accessibility purposes. $coptions['class'] = 'form-control datepicker'; $coptions['placeholder'] = 'YYYY-MM-DD HH:MM:SS'; // TODO: test for date-only inputs and send only the date - $coptions['id'] = $fieldName; + $coptions['id'] = str_replace("_", "-", $fieldName); $entity = $this->getView()->get('vv_obj'); diff --git a/app/templates/element/datePicker.php b/app/templates/element/datePicker.php index 9f9a27210..077242672 100644 --- a/app/templates/element/datePicker.php +++ b/app/templates/element/datePicker.php @@ -4,8 +4,12 @@ $pickerDate = $pickerDate ?? ""; // Create a date/time picker. The yyyy-MM-dd format is set above in $pickerDate. -$pickerId = 'datepicker-' . $fieldName; -$pickerTarget = $fieldName; + +// CAKEPHP transforms snake case variables to kebab when the name has the format of a foreign key. +// As a result searching for the initial key will fail. This is used for use cases +// like the models that use the Tree behavior and have the column parent_id +$pickerId = 'datepicker-' . str_replace("_", "-", $fieldName); +$pickerTarget = str_replace("_", "-", $fieldName); $pickerTimed = $pickerTimed ?? true; // TODO: set false if date-only $pickerAmPm = $pickerAmPm ?? false; // TODO: allow change between AM/PM and 24-hour mode diff --git a/app/templates/element/javascript.php b/app/templates/element/javascript.php index 1922a7736..c10ab0cbf 100644 --- a/app/templates/element/javascript.php +++ b/app/templates/element/javascript.php @@ -128,8 +128,8 @@ e.stopPropagation(); $(this).hide(); $(this)[0].dataset.identifier.split(':').forEach( (ident) => { - // CAKEPHP transforms snake case variables to kebab. As a result - // searching for the initial key will fail. This is used for use cases + // CAKEPHP transforms snake case variables to kebab when the name has the format of a foreign key. + // As a result searching for the initial key will fail. This is used for use cases // like the models that use the Tree behavior and have the column parent_id let ident_to_snake = ident.replace(/_/g, "-"); let filterId = '#' + ident_to_snake;