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
Loading
Loading
Loading
Loading
+1 −0
Changes for core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public static function preRenderCompositeFormElement($element) {

    if (isset($element['#title']) || isset($element['#description'])) {
      // @see #type 'fieldgroup'
      $element['#attributes']['id'] = $element['#id'] . '--wrapper';
      $element['#theme_wrappers'][] = 'fieldset';
      $element['#attributes']['class'][] = 'fieldgroup';
      $element['#attributes']['class'][] = 'form-composite';
+15 −0
Changes for core/modules/system/src/Tests/Form/ElementTest.php: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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.
   */