summaryrefslogtreecommitdiffstats
path: root/core/includes/theme.inc
diff options
context:
space:
mode:
Diffstat (limited to 'core/includes/theme.inc')
-rw-r--r--core/includes/theme.inc13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 3e74521..b3deb32 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1474,8 +1474,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'];
@@ -1492,11 +1490,22 @@ function template_preprocess_field(&$variables, $hook) {
// readers.
$variables['label'] = $element['#title'];
+
+ // @todo Check for is_object() required due to pseudo field used in
+ // quickedit_test_entity_view_alter(). Remove this check after this is fixed
+ // in https://www.drupal.org/node/2550225.
+ $variables['multiple'] = is_object($element['#items']) ? $element['#items']->getFieldDefinition()->getFieldStorageDefinition()->isMultiple() : FALSE;
+
static $default_attributes;
if (!isset($default_attributes)) {
$default_attributes = new Attribute;
}
+ // Merge attributes when a single-value field has a hidden label.
+ if ($element['#label_display'] == 'hidden' && !$variables['multiple'] && is_object($element['#items'][0])) {
+ $variables['attributes'] = NestedArray::mergeDeep($variables['attributes'], (array) $element['#items'][0]->_attributes);
+ }
+
// We want other preprocess functions and the theme implementation to have
// fast access to the field item render arrays. The item render array keys
// (deltas) should always be numerically indexed starting from 0, and looping