From ddb46ebe222632e737134812f16bca3fdf528247 Mon Sep 17 00:00:00 2001 From: webchick <webchick@24967.no-reply.drupal.org> Date: Sun, 8 Dec 2013 13:49:58 -0800 Subject: [PATCH] Issue #2147685 by jibran: Fields settings page breadcrumb is not correct. --- .../Drupal/field_ui/Form/FieldInstanceEditForm.php | 14 ++++++++++++++ .../Drupal/field_ui/Routing/RouteSubscriber.php | 5 ++++- .../lib/Drupal/field_ui/Tests/FieldUiTestBase.php | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php index 8a7650ff36fc..1580fa618a6e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormBase; +use Drupal\Component\Utility\String; use Drupal\field\FieldInstanceInterface; use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -220,4 +221,17 @@ public function delete(array &$form, array &$form_state) { ); } + /** + * The _title_callback for the field instance settings form. + * + * @param \Drupal\field\FieldInstanceInterface $field_instance + * The field instance. + * + * @return string + * The label of the field instance. + */ + public function getTitle(FieldInstanceInterface $field_instance) { + return String::checkPlain($field_instance->label()); + } + } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php index 048630a2b5c9..b703ed474dbd 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Routing/RouteSubscriber.php @@ -70,7 +70,10 @@ protected function routes(RouteCollection $collection) { $route = new Route( "$path/fields/{field_instance}", - array('_form' => '\Drupal\field_ui\Form\FieldInstanceEditForm'), + array( + '_form' => '\Drupal\field_ui\Form\FieldInstanceEditForm', + '_title_callback' => '\Drupal\field_ui\Form\FieldInstanceEditForm::getTitle', + ), array('_permission' => 'administer ' . $entity_type . ' fields') ); $collection->add("field_ui.instance_edit_$entity_type", $route); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php index 705c2b680b41..f103e6d31bce 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php @@ -73,6 +73,8 @@ function fieldUIAddNewField($bundle_path, $initial_edit, $field_edit = array(), // First step : 'Add new field' on the 'Manage fields' page. $this->drupalPostForm("$bundle_path/fields", $initial_edit, t('Save')); $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Field settings page was displayed.'); + // Test Breadcrumbs. + $this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the field settings page.'); // Second step : 'Field settings' form. $this->drupalPostForm(NULL, $field_edit, t('Save field settings')); @@ -129,6 +131,9 @@ function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) { $this->drupalGet("$bundle_path/fields/$field_name/delete"); $this->assertRaw(t('Are you sure you want to delete the field %label', array('%label' => $label)), 'Delete confirmation was found.'); + // Test Breadcrumbs. + $this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the field delete page.'); + // Submit confirmation form. $this->drupalPostForm(NULL, array(), t('Delete')); $this->assertRaw(t('The field %label has been deleted from the %type content type.', array('%label' => $label, '%type' => $bundle_label)), 'Delete message was found.'); -- GitLab