Skip to content
Snippets Groups Projects
Commit c2ac32c9 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2226323 by kpv | danylevskyi: Fixed CompositeFormElementTrait causes...

Issue #2226323 by kpv | danylevskyi: Fixed CompositeFormElementTrait causes identical HTML ids for element and its wrapper.
parent f48a4676
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -32,6 +32,7 @@ public static function preRenderCompositeFormElement($element) { ...@@ -32,6 +32,7 @@ public static function preRenderCompositeFormElement($element) {
if (isset($element['#title']) || isset($element['#description'])) { if (isset($element['#title']) || isset($element['#description'])) {
// @see #type 'fieldgroup' // @see #type 'fieldgroup'
$element['#attributes']['id'] = $element['#id'] . '--wrapper';
$element['#theme_wrappers'][] = 'fieldset'; $element['#theme_wrappers'][] = 'fieldset';
$element['#attributes']['class'][] = 'fieldgroup'; $element['#attributes']['class'][] = 'fieldgroup';
$element['#attributes']['class'][] = 'form-composite'; $element['#attributes']['class'][] = 'form-composite';
......
...@@ -87,6 +87,21 @@ function testOptions() { ...@@ -87,6 +87,21 @@ function testOptions() {
} }
} }
/**
* Tests wrapper ids for checkboxes and radios.
*/
function testWrapperIds() {
$this->drupalGet('form-test/checkboxes-radios');
// Verify that wrapper id is different from element id.
foreach (array('checkboxes', 'radios') as $type) {
$element_ids = $this->xpath('//div[@id=:id]', array(':id' => 'edit-' . $type));
$wrapper_ids = $this->xpath('//fieldset[@id=:id]', array(':id' => 'edit-' . $type . '--wrapper'));
$this->assertTrue(count($element_ids) == 1, format_string('A single element id found for type %type', array('%type' => $type)));
$this->assertTrue(count($wrapper_ids) == 1, format_string('A single wrapper id found for type %type', array('%type' => $type)));
}
}
/** /**
* Tests button classes. * Tests button classes.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment