From 9e4ab53567c2c2e8df0ebac31ede4c1f1c8cbf9c Mon Sep 17 00:00:00 2001 From: ekes Date: Fri, 28 Nov 2025 14:22:08 +0000 Subject: [PATCH 1/3] Allow Title, Help and Description to be set (overriden). Fixes #122 --- src/Element/AddressLookupElement.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Element/AddressLookupElement.php b/src/Element/AddressLookupElement.php index 88dc0f4..5a933af 100644 --- a/src/Element/AddressLookupElement.php +++ b/src/Element/AddressLookupElement.php @@ -109,6 +109,17 @@ public static function processAddressLookupElement(&$element, FormStateInterface 'class' => ['js-address-searchstring'], ], ]; + // Display title, description and help on the active element. + $properties = [ + '#title' => '#title', + // phpcs:ignore DrupalPractice.General.DescriptionT.DescriptionT + '#description' => '#description', + '#help' => '#help', + ]; + $element['address_search']['address_searchstring'] = array_merge( + $element['address_search']['address_searchstring'], + array_intersect_key($element, $properties) + ); $element['address_search']['address_actions'] = [ '#type' => 'container', From c2464db3633653dc287aeb5efd4436f5ef9f7892 Mon Sep 17 00:00:00 2001 From: ekes Date: Fri, 28 Nov 2025 15:15:44 +0000 Subject: [PATCH 2/3] And the option to hide/place the title. --- src/Element/AddressLookupElement.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Element/AddressLookupElement.php b/src/Element/AddressLookupElement.php index 5a933af..be4bc64 100644 --- a/src/Element/AddressLookupElement.php +++ b/src/Element/AddressLookupElement.php @@ -112,6 +112,7 @@ public static function processAddressLookupElement(&$element, FormStateInterface // Display title, description and help on the active element. $properties = [ '#title' => '#title', + '#title_display' => '#title_display', // phpcs:ignore DrupalPractice.General.DescriptionT.DescriptionT '#description' => '#description', '#help' => '#help', From dab6cede95b58a52514f13752eb967e213045336 Mon Sep 17 00:00:00 2001 From: ekes Date: Sat, 29 Nov 2025 16:44:08 +0000 Subject: [PATCH 3/3] Fix for #124. Workaround on a workaround, but. --- .../WebformElement/LocalgovFormsDate.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php b/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php index 4c25ad7..d8d08bd 100644 --- a/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php +++ b/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php @@ -2,6 +2,8 @@ namespace Drupal\localgov_forms_date\Plugin\WebformElement; +use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Datetime\Element\Datelist as CoreDatelist; use Drupal\Core\Datetime\Entity\DateFormat; use Drupal\Core\Form\FormStateInterface; use Drupal\webform\Plugin\WebformElement\DateList; @@ -139,4 +141,27 @@ public static function validateDate(&$element, FormStateInterface $form_state, & parent::validateDate($element, $form_state, $complete_form); } + /** + * {@inheritdoc} + * + * Ensure the datetime object gets added to the user input. + * https://github.com/localgovdrupal/localgov_forms/issues/124 + */ + public static function preValidateDate(&$element, FormStateInterface $form_state, &$complete_form) { + parent::preValidateDate($element, $form_state, $complete_form); + + // Repeating parent workaround to place datetime object on form_state + // input. + $input_exists = FALSE; + $input = NestedArray::getValue($form_state->getValues(), $element['#parents'], $input_exists); + if (!isset($input['object'])) { + if (isset($element['#date_time_element']) && $element['#date_time_element'] === 'timepicker') { + $element['#date_time_format'] = 'H:i:s'; + } + $input = CoreDatelist::valueCallback($element, $input, $form_state); + $form_state->setValueForElement($element, $input); + $element['#value'] = $input; + } + } + }