Commit 1e04c676 authored by webchick's avatar webchick

Issue #2226665 by swentel, Wim Leers: Only set 'add more' wrapper on fields with cardinality >1.

parent 0e21df56
......@@ -155,9 +155,6 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
break;
}
$id_prefix = implode('-', array_merge($parents, array($field_name)));
$wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
$title = String::checkPlain($this->fieldDefinition->getLabel());
$description = field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getDescription()));
......@@ -201,13 +198,17 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
'#required' => $this->fieldDefinition->isRequired(),
'#title' => $title,
'#description' => $description,
'#prefix' => '<div id="' . $wrapper_id . '">',
'#suffix' => '</div>',
'#max_delta' => $max,
);
// Add 'add more' button, if not working with a programmed form.
if ($cardinality == FieldDefinitionInterface::CARDINALITY_UNLIMITED && empty($form_state['programmed'])) {
$id_prefix = implode('-', array_merge($parents, array($field_name)));
$wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
$elements['#prefix'] = '<div id="' . $wrapper_id . '">';
$elements['#suffix'] = '</div>';
$elements['add_more'] = array(
'#type' => 'submit',
'#name' => strtr($id_prefix, '-', '_') . '_add_more',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment