From dff4856ede9da1287a6788ecd2397a71992aedf5 Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 3 Dec 2013 13:40:42 -0800 Subject: [PATCH] Issue #2137837 by dawehner, andypost: Current field is not displayed in replacement patterns. --- .../Plugin/views/field/FieldPluginBase.php | 2 ++ .../lib/Drupal/views_ui/Tests/FieldUITest.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php index fad42d604f2..db4a5d8e295 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php @@ -850,6 +850,8 @@ abstract class FieldPluginBase extends HandlerBase { foreach ($previous as $id => $label) { $options[t('Fields')]["[$id]"] = $label; } + // Add the field to the list of options. + $options[t('Fields')]["[{$this->options['id']}]"] = $this->label(); $count = 0; // This lets us prepare the key as we want it printed. foreach ($this->view->display_handler->getHandlers('argument') as $arg => $handler) { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/FieldUITest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/FieldUITest.php index 725ccd97177..160e99cbeeb 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/FieldUITest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/FieldUITest.php @@ -43,6 +43,25 @@ class FieldUITest extends UITestBase { $this->drupalPostForm($edit_handler_url, array('options[exclude]' => TRUE), t('Apply')); $this->assertText('Views test: Name (Name) [' . t('hidden') . ']'); + + // Ensure that the expected tokens appear in the UI. + $edit_handler_url = 'admin/structure/views/nojs/config-item/test_view/default/field/age'; + $this->drupalGet($edit_handler_url); + $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/fields/li'); + $this->assertEqual((string) $result[0], '[age] == Age'); + + $edit_handler_url = 'admin/structure/views/nojs/config-item/test_view/default/field/id'; + $this->drupalGet($edit_handler_url); + $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/fields/li'); + $this->assertEqual((string) $result[0], '[age] == Age'); + $this->assertEqual((string) $result[1], '[id] == ID'); + + $edit_handler_url = 'admin/structure/views/nojs/config-item/test_view/default/field/name'; + $this->drupalGet($edit_handler_url); + $result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/fields/li'); + $this->assertEqual((string) $result[0], '[age] == Age'); + $this->assertEqual((string) $result[1], '[id] == ID'); + $this->assertEqual((string) $result[2], '[name] == Name'); } }