diff --git a/core/includes/theme.inc b/core/includes/theme.inc index cfdfa89..e3022e2 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,11 @@ function template_preprocess_field(&$variables, $hook) { $variables['field_name'] = $element['#field_name']; $variables['field_type'] = $element['#field_type']; $variables['label_display'] = $element['#label_display']; + if (method_exists($element['#items'], 'getFieldDefinition')) { + $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/modules/system/src/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php index 362f269..b708f32 100644 --- a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php +++ b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php @@ -47,15 +47,17 @@ protected function setUp() { function testEntityViewController() { $get_label_markup = function($label) { return '