.../src/Controller/EntityDisplayModeController.php | 25 ++++++++++++++++------ .../field_ui/src/Form/EntityDisplayFormBase.php | 12 ++++++----- .../tests/src/Functional/FieldUIRouteTest.php | 4 ++-- .../system/src/Tests/Menu/BreadcrumbTest.php | 6 ++++-- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/core/modules/field_ui/src/Controller/EntityDisplayModeController.php b/core/modules/field_ui/src/Controller/EntityDisplayModeController.php index 8edfd45..763a025 100644 --- a/core/modules/field_ui/src/Controller/EntityDisplayModeController.php +++ b/core/modules/field_ui/src/Controller/EntityDisplayModeController.php @@ -12,13 +12,24 @@ class EntityDisplayModeController extends ControllerBase { public function editViewDisplayTitle($entity_type_id, $bundle, $view_mode_name) { - return $this->t('Edit %view-mode-label display of %bundle-label %entity-type-label', [ - '%view-mode-label' => $view_mode_name === 'default' - ? t('default') - : EntityViewMode::load("$entity_type_id.$view_mode_name")->label(), - '%bundle-label' => $this->entityManager()->getBundleInfo($entity_type_id)[$bundle]['label'], - '%entity-type-label' => $this->entityTypeManager()->getDefinition($entity_type_id)->getLowercaseLabel(), - ]); + $entity_type = $this->entityTypeManager()->getDefinition($entity_type_id); + if ($entity_type->hasKey('bundle')) { + return $this->t('Edit %view-mode-label display of %bundle-label %entity-type-label', [ + '%view-mode-label' => $view_mode_name === 'default' + ? t('Default') + : EntityViewMode::load("$entity_type_id.$view_mode_name")->label(), + '%bundle-label' => $this->entityManager()->getBundleInfo($entity_type_id)[$bundle]['label'], + '%entity-type-label' => $this->entityTypeManager()->getDefinition($entity_type_id)->getPluralLabel(), + ]); + } + else { + return $this->t('Edit %view-mode-label display of %entity-type-label', [ + '%view-mode-label' => $view_mode_name === 'default' + ? t('Default') + : EntityViewMode::load("$entity_type_id.$view_mode_name")->label(), + '%entity-type-label' => $this->entityTypeManager()->getDefinition($entity_type_id)->getPluralLabel(), + ]); + } } /** * Provides a list of eligible entity types for adding view modes. diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index 4d664b6..6f22d6b 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -245,12 +245,14 @@ public function form(array $form, FormStateInterface $form_state) { '#attributes' => ['class' => ['visually-hidden']] ]; + $form['#attached']['library'][] = 'core/drupal.dialog.ajax'; $form['actions'] = ['#type' => 'actions']; - $form['actions']['submit'] = [ - '#type' => 'submit', - '#button_type' => 'primary', - '#value' => $this->t('Save'), - ]; +// $form['actions']['submit'] = [ +// '#type' => 'submit', +// '#attributes' => ['foo' => 'bar'], +// '#button_type' => 'primary', +// '#value' => $this->t('Save'), +// ]; $form['#attached']['library'][] = 'field_ui/drupal.field_ui'; diff --git a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php index fe7a270..1b27d27 100644 --- a/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php +++ b/core/modules/field_ui/tests/src/Functional/FieldUIRouteTest.php @@ -46,13 +46,13 @@ public function testFieldUIRoutes() { $this->assertResponse(403); $this->drupalGet('admin/config/people/accounts/display'); - $this->assertTitle('Manage display | Drupal'); + $this->assertTitle('Edit Default display of user entities | Drupal'); $this->assertLocalTasks(); $edit = ['display_modes_custom[compact]' => TRUE]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalGet('admin/config/people/accounts/display/compact'); - $this->assertTitle('Manage display | Drupal'); + $this->assertTitle('Edit Compact display of user entities | Drupal'); $this->assertLocalTasks(); // Test manage form display tabs and titles. diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index 39303ff..cc9f101 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -110,10 +110,12 @@ public function testBreadCrumbs() { ]; $this->assertBreadcrumb("admin/structure/types/manage/$type/fields", $trail); $this->assertBreadcrumb("admin/structure/types/manage/$type/display", $trail); + $title_html = t('Edit %view-mode-label display of %bundle-label %entity-type-label', ['%view-mode-label' => 'Teaser', '%bundle-label' => NodeType::load($type)->label(), '%entity-type-label' => 'content items']); $trail_teaser = $trail + [ - "admin/structure/types/manage/$type/display" => t('Manage display'), + // @todo Improve ::assertBreadcrumbParts() + "admin/structure/types/manage/$type/display" => 'Edit display of ', ]; - $this->assertBreadcrumb("admin/structure/types/manage/$type/display/teaser", $trail_teaser); + $this->assertBreadcrumb("admin/structure/types/manage/$type/display/teaser", $trail_teaser, strip_tags($title_html)); $this->assertBreadcrumb("admin/structure/types/manage/$type/delete", $trail); $trail += [ "admin/structure/types/manage/$type/fields" => t('Manage fields'),