diff -u b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php --- b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -853,19 +853,8 @@ // When the operator and value forms are both in play, enclose them within // a wrapper, for usability. if (!empty($this->options['expose']['identifier'])) { - $value = $this->options['expose']['identifier']; - $wrapper = $value . '_wrapper'; - $form[$wrapper] = [ - '#type' => 'fieldset', - ]; - - $exposed_info = $this->exposedInfo(); - if (!empty($exposed_info['label'])) { - $form[$wrapper]['#title'] = $exposed_info['label']; - } - if (!empty($exposed_info['description'])) { - $form[$wrapper]['#description'] = $exposed_info['description']; - } + $wrapper = $this->options['expose']['identifier'] . '_wrapper'; + $this->buildValueWrapper($form, $wrapper); $form[$operator]['#title_display'] = 'invisible'; $form[$wrapper][$operator] = $form[$operator]; @@ -901,9 +890,35 @@ - // a wrapper, for usability. - if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) { + // a wrapper, for usability. Also wrap if the value form is comprised of + // multiple elements. + if ((!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) || count(Element::children($form[$value]))) { $wrapper = $value . '_wrapper'; + $this->buildValueWrapper($form, $wrapper); $form[$wrapper][$value] = $form[$value]; unset($form[$value]); } } } + /** + * Builds wrapper for value and operator forms. + * + * @param array $form + * The form. + * @param string $wrapper_identifer + * The key to use for the wrapper element. + */ + protected function buildValueWrapper(&$form, $wrapper_identifer) { + if (!isset($form[$wrapper_identifer])) { + $form[$wrapper_identifer] = [ + '#type' => 'fieldset', + ]; + + $exposed_info = $this->exposedInfo(); + if (!empty($exposed_info['label'])) { + $form[$wrapper_identifer]['#title'] = $exposed_info['label']; + } + if (!empty($exposed_info['description'])) { + $form[$wrapper_identifer]['#description'] = $exposed_info['description']; + } + } + } + only in patch2: unchanged: --- a/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php +++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php @@ -109,10 +109,10 @@ class FilterNumericWebTest extends UITestBase { $this->drupalPostForm(NULL, [], t('Update preview')); // Check the max field label. - $this->assertRaw('', 'Max field label found'); - $this->assertRaw('', 'Min field label found'); + $this->assertRaw('', 'Max field label found'); + $this->assertRaw('', 'Min field label found'); // Check that the description is shown in the right place. - $this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]->getText()), 'Description of the exposed filter'); + $this->assertEqual(trim($this->cssSelect('#edit-age-wrapper--description')[0]->getText()), 'Description of the exposed filter'); } }