diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 239ff956958c92883fa7628c4d11c0d18466039f..64b62efae87eee3ec2ee854ab0fea5bab622f63f 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -11,6 +11,7 @@ use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Entity\EntityViewModeInterface; +use Drupal\Core\Entity\EntityFormModeInterface; use Drupal\Core\Url; use Drupal\field_ui\FieldUI; use Drupal\field_ui\Plugin\Derivative\FieldUiLocalTask; @@ -165,16 +166,30 @@ function field_ui_form_node_type_form_submit($form, FormStateInterface $form_sta } /** - * Implements hook_view_mode_presave(). + * Implements hook_entity_view_mode_presave(). */ -function field_ui_view_mode_presave(EntityViewModeInterface $view_mode) { +function field_ui_entity_view_mode_presave(EntityViewModeInterface $view_mode) { \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } /** - * Implements hook_view_mode_delete(). + * Implements hook_entity_form_mode_presave(). */ -function field_ui_view_mode_delete(EntityViewModeInterface $view_mode) { +function field_ui_entity_form_mode_presave(EntityFormModeInterface $form_mode) { + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); +} + +/** + * Implements hook_entity_view_mode_delete(). + */ +function field_ui_entity_view_mode_delete(EntityViewModeInterface $view_mode) { + \Drupal::service('router.builder_indicator')->setRebuildNeeded(); +} + +/** + * Implements hook_entity_form_mode_delete(). + */ +function field_ui_entity_form_mode_delete(EntityFormModeInterface $form_mode) { \Drupal::service('router.builder_indicator')->setRebuildNeeded(); } diff --git a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php index 6220bfaa3153d90df48404fd5578f43d1a8f57a4..6ca3df969caf3ad7be42bf926e3ca31067827f2b 100644 --- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php +++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php @@ -72,6 +72,28 @@ public function testFieldUIRoutes() { $this->assertTitle('Manage form display | Drupal'); $this->assertLocalTasks(); $this->assert(count($this->xpath('//ul/li[1]/a[contains(text(), :text)]', array(':text' => 'Default'))) == 1, 'Default secondary tab is in first position.'); + + // Create new view mode and verify it's available on the Manage Display + // screen after enabling it. + entity_create('entity_view_mode' ,array( + 'id' => 'user.test', + 'label' => 'Test', + 'targetEntityType' => 'user', + ))->save(); + $edit = array('display_modes_custom[test]' => TRUE); + $this->drupalPostForm('admin/config/people/accounts/display', $edit, t('Save')); + $this->assertLink('Test'); + + // Create new form mode and verify it's available on the Manage Form + // Display screen after enabling it. + entity_create('entity_form_mode' ,array( + 'id' => 'user.test', + 'label' => 'Test', + 'targetEntityType' => 'user', + ))->save(); + $edit = array('display_modes_custom[test]' => TRUE); + $this->drupalPostForm('admin/config/people/accounts/form-display', $edit, t('Save')); + $this->assertLink('Test'); } /**