commit 2fbcd2850a8c7360cf53191f2880c4d4be911896 Author: Joel Pittet Date: Sun Feb 23 17:27:03 2014 -0800 rtl ltr and fieldset labels diff --git a/core/includes/form.inc b/core/includes/form.inc index e6b5d26..5cc4d24 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -1021,15 +1021,10 @@ function theme_fieldset($variables) { $element['#attributes']['aria-describedby'] = $description_id; } - // If the element is required, a required marker is appended to the label. - // @see theme_form_element_label() - $required = ''; + // If the element is required, a form-required class is appended to + // the fieldset. if (!empty($element['#required'])) { - $marker = array( - '#theme' => 'form_required_marker', - '#element' => $element, - ); - $required = drupal_render($marker); + $element['#attributes']['class'][] = 'form-required'; } $legend_attributes = array(); @@ -1042,7 +1037,7 @@ function theme_fieldset($variables) { if ((isset($element['#title']) && $element['#title'] !== '') || !empty($element['#required'])) { // Always wrap fieldset legends in a SPAN for CSS positioning. $output .= ''; - $output .= t('!title!required', array('!title' => $element['#title'], '!required' => $required)); + $output .= $element['#title']; $output .= ''; } $output .= '
'; @@ -2939,7 +2934,7 @@ function theme_form_element_label($variables) { $attributes['for'] = $element['#id']; } - return '' . t('!title', array('!title' => $title)) . ''; + return '' . $title . ''; } /** diff --git a/core/modules/system/css/system.theme.css b/core/modules/system/css/system.theme.css index 9361908..7bdc81f 100644 --- a/core/modules/system/css/system.theme.css +++ b/core/modules/system/css/system.theme.css @@ -82,15 +82,29 @@ h4.label { .marker { color: #e00; } + +.form-required label:not(.option):before, .form-required label:not(.option):after, +.form-required .fieldset-legend:before +.form-required .fieldset-legend:after +.form-required .label:before .form-required .label:after { - content: "*"; speak: none; color: #e00; } -/* -Not sure how to deal with this... -abbr.form-required, */ + +[dir="ltr"] .form-required label:not(.option):after, +[dir="ltr"] .form-required .fieldset-legend:not(.option):after, +[dir="ltr"] .form-required .label:after { + content: "*"; +} + +[dir="rtl"] .form-required label:not(.option):before, +[dir="rtl"] .form-required .fieldset-legend:not(.option):before, +[dir="rtl"] .form-required .label:before { + content: "*"; +} + abbr.tabledrag-changed, abbr.ajax-changed { border-bottom: none; 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 5aabe17..8bb3c0e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php @@ -96,7 +96,7 @@ function testRequiredFields() { // Regular expression to find the expected marker on required elements. - $required_marker_preg = '@
@'; + $required_marker_preg = '@<(?:div|fieldset) class=".*?form-required.*?">@'; // Go through all the elements and all the empty values for them. foreach ($elements as $type => $data) { foreach ($data['empty_values'] as $key => $empty) { diff --git a/core/modules/system/templates/form-required-marker.html.twig b/core/modules/system/templates/form-required-marker.html.twig deleted file mode 100644 index 8e28020..0000000 --- a/core/modules/system/templates/form-required-marker.html.twig +++ /dev/null @@ -1,12 +0,0 @@ -{# -/** - * @file - * Default theme implementation for a form element required marker. - * - * Available variables: - * - attributes: A list of HTML attributes for the marker. - * - * @ingroup themeable - */ -#} -