diff --git a/core/lib/Drupal/Core/Render/Element/Checkboxes.php b/core/lib/Drupal/Core/Render/Element/Checkboxes.php index 117f839..994f76e 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkboxes.php +++ b/core/lib/Drupal/Core/Render/Element/Checkboxes.php @@ -84,7 +84,8 @@ public static function processCheckboxes(&$element, FormStateInterface $form_sta '#title' => $choice, '#return_value' => $key, '#default_value' => isset($value[$key]) ? $key : NULL, - '#attributes' => $element['#attributes'], + // Remove the data-drupal-selector from the passed along attributes. + '#attributes' => isset($element['#attributes']['data-drupal-selector']) ? array_diff($element['#attributes'], ['data-drupal-selector' => $element['#attributes']['data-drupal-selector']]) : $element['#attributes'], '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, // Errors should only be shown on the parent checkboxes element. '#error_no_message' => TRUE, diff --git a/core/lib/Drupal/Core/Render/Element/Container.php b/core/lib/Drupal/Core/Render/Element/Container.php index 9c58f54..9082c1d 100644 --- a/core/lib/Drupal/Core/Render/Element/Container.php +++ b/core/lib/Drupal/Core/Render/Element/Container.php @@ -54,7 +54,9 @@ public function getInfo() { public static function processContainer(&$element, FormStateInterface $form_state, &$complete_form) { // Generate the ID of the element if it's not explicitly given. if (!isset($element['#id'])) { - $element['#id'] = HtmlUtility::getUniqueId(implode('-', $element['#parents']) . '-wrapper'); + $wrapper_id = implode('-', $element['#parents']) . '-wrapper'; + $element['#id'] = HtmlUtility::getUniqueId($wrapper_id); + $element['#attributes']['data-drupal-selector'] = HtmlUtility::getId($wrapper_id); } return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Radios.php b/core/lib/Drupal/Core/Render/Element/Radios.php index 5423ef0..f4b4f4e 100644 --- a/core/lib/Drupal/Core/Render/Element/Radios.php +++ b/core/lib/Drupal/Core/Render/Element/Radios.php @@ -79,7 +79,7 @@ public static function processRadios(&$element, FormStateInterface $form_state, // Use default or FALSE. A value of FALSE means that the radio button is // not 'checked'. '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : FALSE, - '#attributes' => $element['#attributes'], + '#attributes' => ['data-drupal-selector' => HtmlUtility::getId('edit-' . implode('-', $parents_for_id))] + $element['#attributes'], '#parents' => $element['#parents'], '#id' => HtmlUtility::getUniqueId('edit-' . implode('-', $parents_for_id)), '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,