diff --git a/core/includes/theme.inc b/core/includes/theme.inc index de21bfe9112..246aa63b18e 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1606,6 +1606,7 @@ function template_preprocess_field(&$variables, $hook) { function template_preprocess_field_multiple_value_form(&$variables) { $element = $variables['element']; $variables['multiple'] = $element['#cardinality_multiple']; + $variables['attributes'] = $element['#attributes']; if ($variables['multiple']) { $table_id = Html::getUniqueId($element['#field_name'] . '_values'); diff --git a/core/modules/field/tests/src/Functional/FormTest.php b/core/modules/field/tests/src/Functional/FormTest.php index c1b135f0433..95efcb49bdb 100644 --- a/core/modules/field/tests/src/Functional/FormTest.php +++ b/core/modules/field/tests/src/Functional/FormTest.php @@ -403,11 +403,12 @@ class FormTest extends FieldTestBase { $this->field['field_name'] = $field_name; FieldStorageConfig::create($field_storage)->save(); FieldConfig::create($this->field)->save(); - entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default') + $form = entity_get_form_display($this->field['entity_type'], $this->field['bundle'], 'default') ->setComponent($field_name, [ 'type' => 'test_field_widget_multiple', - ]) - ->save(); + ]); + $form->save(); + $session = $this->assertSession(); // Display creation form. $this->drupalGet('entity_test/add'); @@ -435,6 +436,16 @@ class FormTest extends FieldTestBase { $this->assertRaw('this field cannot hold more than 4 values', 'Form validation failed.'); // Check that the field values were not submitted. $this->assertFieldValues($entity_init, $field_name, [1, 2, 3]); + + // Check that Attributes are rendered on the multivalue container if it is + // a multiple widget form. + $form->setComponent($field_name, [ + 'type' => 'entity_reference_autocomplete', + ]) + ->save(); + $this->drupalGet('entity_test/manage/' . $id . '/edit'); + $name = str_replace('_', '-', $field_name); + $session->responseContains('data-drupal-selector="edit-' . $name . '"'); } /** diff --git a/core/modules/system/templates/field-multiple-value-form.html.twig b/core/modules/system/templates/field-multiple-value-form.html.twig index 1108d6eb76b..832b9f61794 100644 --- a/core/modules/system/templates/field-multiple-value-form.html.twig +++ b/core/modules/system/templates/field-multiple-value-form.html.twig @@ -22,7 +22,13 @@ */ #} {% if multiple %} -