diff --git a/core/includes/form.inc b/core/includes/form.inc index 3617a1a..ca4b3a4 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -962,10 +962,20 @@ function theme_fieldset($variables) { // Hide box for fieldset by default. $element['#attributes']['class'][] = 'fieldset-no-border'; - $output = ''; + // Add a class for disabled elements to facilitate cross-browser styling. + if (!empty($element['#attributes']['disabled'])) { + $element['#attributes']['class'][] = 'form-disabled'; + } + $prefix = isset($element['#field_prefix']) ? '' . $element['#field_prefix'] . ' ' : ''; + $suffix = isset($element['#field_suffix']) ? ' ' . $element['#field_suffix'] . '' : ''; + + $output = $prefix . ''; if (!empty($element['#title'])) { + $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; + + $title = filter_xss_admin($element['#title']); // Always wrap fieldset legends in a SPAN for CSS positioning. - $output .= '' . $element['#title'] . ''; + $output .= '' . $title . '' . $required . ''; } $output .= '
'; if (!empty($element['#description'])) { @@ -974,11 +984,8 @@ function theme_fieldset($variables) { } $output .= $element['#children']; - if (isset($element['#value'])) { - $output .= $element['#value']; - } $output .= '
'; - $output .= "\n"; + $output .= "\n" . $suffix; return $output; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ElementsLabelsTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ElementsLabelsTest.php index 6c51a04..02bc1d9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/ElementsLabelsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/ElementsLabelsTest.php @@ -78,10 +78,10 @@ function testFormLabels() { $this->assertFalse(isset($elements[0]), 'No label tag when title set not to display.'); // Check #field_prefix and #field_suffix placement. - $elements = $this->xpath('//span[@class="field-prefix"]/following-sibling::div[@id="edit-form-radios-test"]'); + $elements = $this->xpath('//span[@class="field-prefix"]/following-sibling::fieldset[@id="edit-form-radios-test"]'); $this->assertTrue(isset($elements[0]), 'Properly placed the #field_prefix element after the label and before the field.'); - $elements = $this->xpath('//span[@class="field-suffix"]/preceding-sibling::div[@id="edit-form-radios-test"]'); + $elements = $this->xpath('//span[@class="field-suffix"]/preceding-sibling::fieldset[@id="edit-form-radios-test"]'); $this->assertTrue(isset($elements[0]), 'Properly places the #field_suffix element immediately after the form field.'); // Check #prefix and #suffix placement. diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php index 6563339..8ebf450 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php @@ -94,7 +94,7 @@ function testRequiredFields() { $elements['file']['empty_values'] = $empty_strings; // Regular expression to find the expected marker on required elements. - $required_marker_preg = '@