diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f98df80..3896d71 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2418,6 +2418,12 @@ function template_preprocess_field(&$variables, $hook) { $delta++; } + // We have to know if the field has multiple values to create a simple value + // or a list. + if (count($variables['items']) > 1 ) { + $variables['multiple'] = TRUE; + } + // Add default CSS classes. Since there can be many fields rendered on a page, // save some overhead by calling strtr() directly instead of // drupal_html_class(). diff --git a/core/modules/system/templates/field.html.twig b/core/modules/system/templates/field.html.twig index a0d527a..9a62a5f 100644 --- a/core/modules/system/templates/field.html.twig +++ b/core/modules/system/templates/field.html.twig @@ -33,9 +33,27 @@ {% if not label_hidden %}
{{ label }}: 
{% endif %} -
- {% for delta, item in items %} -
{{ item }}
- {% endfor %} + +{% if multiple %} +
+ {% if not label_hidden %} +
{{ label }}
+ {% endif %} +
+ {% else %} + {% for delta, item in items %} +
+ {% if not label_hidden %} +
{{ label }}
+ {% endif %} + {{ item }} +
+ {% endfor %} +{% endif %} +