From a03a23b21bbb83b1b07a6cfb95590946eeb45acc Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Tue, 14 Jun 2016 16:28:38 +0100 Subject: [PATCH] Issue #2732091 by damiankloip: Boolean exposed filter value widget just shows 'True' label --- core/modules/views/src/Plugin/ViewsHandlerManager.php | 2 +- .../views/src/Plugin/views/filter/BooleanOperator.php | 5 +++++ core/modules/views_ui/src/Tests/FilterBooleanWebTest.php | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/views/src/Plugin/ViewsHandlerManager.php b/core/modules/views/src/Plugin/ViewsHandlerManager.php index d138d72d054a..d918696d6743 100644 --- a/core/modules/views/src/Plugin/ViewsHandlerManager.php +++ b/core/modules/views/src/Plugin/ViewsHandlerManager.php @@ -86,7 +86,7 @@ public function getHandler($item, $override = NULL) { if (isset($data[$field][$this->handlerType])) { $definition = $data[$field][$this->handlerType]; - foreach (array('group', 'title', 'title short', 'help', 'real field', 'real table', 'entity type', 'entity field') as $key) { + foreach (array('group', 'title', 'title short', 'label', 'help', 'real field', 'real table', 'entity type', 'entity field') as $key) { if (!isset($definition[$key])) { // First check the field level. if (!empty($data[$field][$key])) { diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php index 616666be4359..7078032e89da 100644 --- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php +++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php @@ -93,9 +93,14 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o parent::init($view, $display, $options); $this->value_value = $this->t('True'); + if (isset($this->definition['label'])) { $this->value_value = $this->definition['label']; } + elseif (isset($this->definition['title'])) { + $this->value_value = $this->definition['title']; + } + if (isset($this->definition['accept null'])) { $this->accept_null = (bool) $this->definition['accept null']; } diff --git a/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php b/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php index 3faca0c7b12d..668cc4c1de11 100644 --- a/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php +++ b/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php @@ -23,6 +23,10 @@ class FilterBooleanWebTest extends UITestBase { public function testFilterBooleanUI() { $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', array('name[views_test_data.status]' => TRUE), t('Add and configure @handler', array('@handler' => t('filter criteria')))); + // Check the field widget label. 'title' should be used as a fallback. + $result = $this->cssSelect('#edit-options-value--wrapper legend span'); + $this->assertEqual((string) $result[0], 'Status'); + $this->drupalPostForm(NULL, array(), t('Expose filter')); $this->drupalPostForm(NULL, array(), t('Grouped filters')); -- GitLab