From 6b9ecae59f424d89b77096c6b46b2986a48023f5 Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Tue, 24 Oct 2017 14:11:48 -0700 Subject: [PATCH] Issue #2915036 by Dane Powell: Fixed view modes not updating in response to new fields. --- core/modules/field_ui/src/Form/FieldStorageAddForm.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php index e1f278796e..766e47d995 100644 --- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php @@ -428,7 +428,7 @@ protected function configureEntityFormDisplay($field_name, $widget_id = NULL) { } /** - * Configures the field for the default view mode. + * Configures the field for active view modes.. * * @param string $field_name * The field name. @@ -443,6 +443,15 @@ protected function configureEntityViewDisplay($field_name, $formatter_id = NULL) entity_get_display($this->entityTypeId, $this->bundle, 'default') ->setComponent($field_name, $options) ->save(); + // Allow other view modes to update their configuration in response to the + // new field. + $view_modes = $this->entityManager->getViewModes($this->entityTypeId); + foreach ($view_modes as $id => $view_mode) { + if ($view_mode['status']) { + entity_get_display($this->entityTypeId, $this->bundle, $id) + ->save(); + } + } } /** -- 2.14.1