summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-03-01 13:29:28 (GMT)
committerAlex Pott2015-03-01 13:29:28 (GMT)
commit0b5587bf86876718d0955dab0943b2abd1c16264 (patch)
treeaed9c4353eaf5475d3d6adee99c329c1f64bf6c3
parentf15361912489af8563cce4cce8cc6d83f7f08350 (diff)
Issue #2341455 by swentel, cosmicdreams: Creating a new view mode should clear cache, so the new view mode can be displayed
-rw-r--r--core/modules/field_ui/field_ui.module23
-rw-r--r--core/modules/field_ui/src/Tests/FieldUIRouteTest.php22
2 files changed, 41 insertions, 4 deletions
diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module
index 239ff95..64b62ef 100644
--- a/core/modules/field_ui/field_ui.module
+++ b/core/modules/field_ui/field_ui.module
@@ -11,6 +11,7 @@ use Drupal\Core\Form\FormStateInterface;
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 6220bfa..6ca3df9 100644
--- a/core/modules/field_ui/src/Tests/FieldUIRouteTest.php
+++ b/core/modules/field_ui/src/Tests/FieldUIRouteTest.php
@@ -72,6 +72,28 @@ class FieldUIRouteTest extends WebTestBase {
$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');
}
/**