Issue #3004738 by NickWilde: Multiple Value Field Doesn't Render Attributes
parent
a92a3693ee
commit
18c57b6f71
|
@ -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');
|
||||
|
|
|
@ -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 . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,13 @@
|
|||
*/
|
||||
#}
|
||||
{% if multiple %}
|
||||
<div class="js-form-item form-item">
|
||||
{%
|
||||
set classes = [
|
||||
'js-form-item',
|
||||
'form-item'
|
||||
]
|
||||
%}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{{ table }}
|
||||
{% if description.content %}
|
||||
<div{{ description.attributes.addClass('description') }} >{{ description.content }}</div>
|
||||
|
|
|
@ -20,7 +20,13 @@
|
|||
*/
|
||||
#}
|
||||
{% if multiple %}
|
||||
<div class="js-form-item form-item">
|
||||
{%
|
||||
set classes = [
|
||||
'js-form-item',
|
||||
'form-item'
|
||||
]
|
||||
%}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{{ table }}
|
||||
{% if description.content %}
|
||||
<div{{ description.attributes.addClass('description') }} >{{ description.content }}</div>
|
||||
|
|
|
@ -19,8 +19,15 @@
|
|||
* @see template_preprocess_field_multiple_value_form()
|
||||
*/
|
||||
#}
|
||||
|
||||
{% if multiple %}
|
||||
<div class="js-form-item form-item">
|
||||
{%
|
||||
set classes = [
|
||||
'js-form-item',
|
||||
'form-item'
|
||||
]
|
||||
%}
|
||||
<div{{ attributes.addClass(classes) }}>
|
||||
{{ table }}
|
||||
{% if description.content %}
|
||||
<div{{ description.attributes.addClass('description') }} >{{ description.content }}</div>
|
||||
|
|
Loading…
Reference in New Issue