';
if (!empty($element['#description'])) {
$output .= '
' . $element['#description'] . '
';
@@ -4374,15 +4381,31 @@ function theme_form_element($variables) {
if (!empty($element['#attributes']['disabled'])) {
$attributes['class'][] = 'form-disabled';
}
+
+ $prefix = isset($element['#field_prefix']) ? '
' . $element['#field_prefix'] . ' ' : '';
+ $suffix = isset($element['#field_suffix']) ? '
' . $element['#field_suffix'] . '' : '';
+
+ // Composite elements consist of more than one HTML form control. These must
+ // be grouped by a fieldset.
+ if (isset($element['#composite']) && $element['#composite'] === TRUE) {
+ $fieldset_variables = array('element' => array());
+ $fieldset_variables['element']['#children'] = $prefix . $element['#children'] . $suffix;
+ foreach (array('#attributes', '#description', '#id', '#title', '#title_display') as $property) {
+ if (!empty($element[$property])) {
+ $fieldset_variables['element'][$property] = $element[$property];
+ }
+ }
+ unset($fieldset_variables['element']['#attributes']['disabled']);
+ $fieldset_variables['element']['#title'] .= !empty($element['#required']) ? ' ' . theme('form_required_marker', array('element' => $element)) : '';
+ return theme('fieldset', $fieldset_variables);
+ }
+
$output = '
' . "\n";
// If #title is not set, we don't display any label or required marker.
if (!isset($element['#title'])) {
$element['#title_display'] = 'none';
}
- $prefix = isset($element['#field_prefix']) ? '
' . $element['#field_prefix'] . ' ' : '';
- $suffix = isset($element['#field_suffix']) ? '
' . $element['#field_suffix'] . '' : '';
-
switch ($element['#title_display']) {
case 'before':
case 'invisible':
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 20d1f56..e4ebc14 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php
@@ -88,7 +88,7 @@ class FormTest extends WebTestBase {
$elements['file']['empty_values'] = $empty_strings;
// Regular expression to find the expected marker on required elements.
- $required_marker_preg = '@
\*@';
+ $required_marker_preg = '@<(label|legend).*\*.*\1>@';
// Go through all the elements and all the empty values for them.
foreach ($elements as $type => $data) {
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index b9558e5..b3ac340 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -458,6 +458,7 @@ function system_element_info() {
'#theme_wrappers' => array('form_element'),
);
$types['radios'] = array(
+ '#composite' => TRUE,
'#input' => TRUE,
'#process' => array('form_process_radios'),
'#theme_wrappers' => array('radios'),
@@ -472,6 +473,7 @@ function system_element_info() {
'#title_display' => 'after',
);
$types['checkboxes'] = array(
+ '#composite' => TRUE,
'#input' => TRUE,
'#process' => array('form_process_checkboxes'),
'#theme_wrappers' => array('checkboxes'),
@@ -499,6 +501,7 @@ function system_element_info() {
'#process' => array('form_process_weight', 'ajax_process_form'),
);
$types['date'] = array(
+ '#composite' => TRUE,
'#input' => TRUE,
'#element_validate' => array('date_validate'),
'#process' => array('form_process_date'),