diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index cc13ae4..15ecaef 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -176,21 +176,10 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f // For multiple fields, title and description are handled by the wrapping // table. - if ($is_multiple) { - $element = [ - '#title' => $title . ' ' . $this->t('(value @number)', ['@number' => $delta + 1]), - '#title_display' => 'invisible', - '#description' => '', - ]; - } - else { - $element = [ - '#title' => $title, - '#title_display' => 'before', - '#description' => $description, - ]; - } - + $element = array( + '#title' => $is_multiple ? '' : $title, + '#description' => $is_multiple ? '' : $description, + ); $element = $this->formSingleElement($items, $delta, $element, $form, $form_state); if ($element) { @@ -200,7 +189,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f // defined by widget. $element['_weight'] = array( '#type' => 'weight', - '#title' => $this->t('Weight for row @number', array('@number' => $delta + 1)), + '#title' => t('Weight for row @number', array('@number' => $delta + 1)), '#title_display' => 'invisible', // Note: this 'delta' is the FAPI #type 'weight' element's property. '#delta' => $max, diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php index 748d2ac..4b21bc4 100644 --- a/core/modules/field/src/Tests/FormTest.php +++ b/core/modules/field/src/Tests/FormTest.php @@ -334,12 +334,12 @@ public function testFieldFormUnlimitedRequired() { // Display creation form -> 1 widget. $this->drupalGet('entity_test/add'); // Check that the Required symbol is present for the multifield label. - $this->assertRaw(SafeMarkup::format('

@label

', array('@label' => $this->field['label'])), - 'Required symbol added field label.'); + $element = $this->xpath('//h4[contains(@class, "label") and contains(@class, "js-form-required") and contains(text(), :value)]', array(':value' => $this->field['label'])); + $this->assertTrue(isset($element[0]), 'Required symbol added field label.'); // Check that the label of the field input is visually hidden and contains // the field title and an indication of the delta for a11y. - $this->assertRaw(SafeMarkup::format('', array('@label' => $this->field['label'])), - 'Required symbol not added for field input.'); + $element = $this->xpath('//label[@for=:for and contains(@class, "js-form-required") and contains(text(), :value)]', array(':for' => 'edit-field-unlimited-0-value', ':value' => $this->field['label'] . ' (value 1)')); + $this->assertTrue(isset($element[0]), 'Required symbol not added for field input.'); } /**