diff --git a/core/includes/theme.inc b/core/includes/theme.inc index d3d8553..2eba338 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1544,7 +1544,7 @@ function template_preprocess_field(&$variables, $hook) { $variables['label_display'] = $element['#label_display']; // Are there multiple field items. $variables['multiple'] = FALSE; - if (isset($element['#items']) && is_callable($element['#items']->getFieldDefinition(), 'isMultiple')) { + if (isset($element['#items']) && is_callable($element['#items'], 'getFieldDefinition') && is_callable($element['#items']->getFieldDefinition(), 'isMultiple')) { $variables['multiple'] = $element['#items']->getFieldDefinition()->isMultiple(); } @@ -1563,11 +1563,11 @@ function template_preprocess_field(&$variables, $hook) { $variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], $variables['content_attributes']); } // Merge the attributes when its a single field with a label - if ($element['#label_display'] != 'hidden' && !$variables['multiple']) { + if ($element['#label_display'] != 'hidden' && !$variables['multiple'] && is_object($element['#items'][0])) { $variables['content_attributes'] = NestedArray::mergeDeep($variables['content_attributes'], (array) $element['#items'][0]->_attributes); } // Merge the attributes when its a single field with hidden label - if ($element['#label_display'] == 'hidden' && !$variables['multiple']) { + if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && is_object($element['#items'][0])) { $variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], $variables['content_attributes'], (array) $element['#items'][0]->_attributes); }