diff --git a/core/includes/theme.inc b/core/includes/theme.inc index cfdfa89..cc8cf64 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1490,8 +1490,6 @@ function template_preprocess_region(&$variables) { * - element: A render element representing the field. * - attributes: A string containing the attributes for the wrapping div. * - title_attributes: A string containing the attributes for the title. - * - content_attributes: A string containing the attributes for the content's - * div. */ function template_preprocess_field(&$variables, $hook) { $element = $variables['element']; @@ -1501,6 +1499,8 @@ function template_preprocess_field(&$variables, $hook) { $variables['field_name'] = $element['#field_name']; $variables['field_type'] = $element['#field_type']; $variables['label_display'] = $element['#label_display']; + $fieldStorageDefinition = $element['#items']->getFieldDefinition()->getFieldStorageDefinition(); + $variables['cardinality'] = $fieldStorageDefinition->getCardinality(); $variables['label_hidden'] = ($element['#label_display'] == 'hidden'); // Always set the field label - allow themes to decide whether to display it. diff --git a/core/themes/classy/templates/field/field.html.twig b/core/themes/classy/templates/field/field.html.twig index 5ab1e92..2dea023 100644 --- a/core/themes/classy/templates/field/field.html.twig +++ b/core/themes/classy/templates/field/field.html.twig @@ -24,7 +24,6 @@ * - label_hidden: Whether to show the field label or not. * - title_attributes: HTML attributes for the title. * - label: The label for the field. - * - content_attributes: HTML attributes for the content. * - items: List of all the field items. Each item contains: * - attributes: List of HTML attributes for each item. * - content: The field item's content. @@ -32,6 +31,7 @@ * - field_name: The name of the field. * - field_type: The type of the field. * - label_display: The display settings for the label. + * - cardinality: The maximum possible number of items as set in the field configuration. * * @see template_preprocess_field() */ @@ -57,9 +57,13 @@ {% if not label_hidden %} {{ label }} {% endif %} - - {% for item in items %} - {{ item.content }} - {% endfor %} - + {% if cardinality != 1 %} +
+ {% endif %} + {% for item in items %} + {{ item.content }}
+ {% endfor %} + {% if cardinality != 1 %} + + {% endif %}