diff --git a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php index 1e02d397af..515cdd2e8f 100644 --- a/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php @@ -180,14 +180,15 @@ protected function valueForm(&$form, FormStateInterface $form_state) { return; } - $vocabulary_labels = "'" . implode("', '", $this->getVocabularyLabels($vocabularies)) . "'"; + $form['value'] = [ + '#title' => $this->options['limit'] ? $this->formatPlural(count($vocabularies), 'Select terms from vocabulary @vocabs', 'Select terms from vocabularies @vocabs', [ + '@vocabs' => "'" . implode("', '", $this->getVocabularyLabels($vocabularies)) . "'", + ]) : $this->t('Select terms'), + ]; if ($this->options['type'] == 'textfield') { $terms = $this->value ? $this->termStorage->loadMultiple($this->value) : []; - $form['value'] = [ - '#title' => $this->options['limit'] ? $this->t("Select terms from vocabularies @vocabs", [ - '@vocabs' => $vocabulary_labels, - ]) : $this->t('Select terms'), + $form['value'] += [ '#type' => 'textfield', '#default_value' => EntityAutocomplete::getEntityLabels($terms), ]; @@ -201,9 +202,8 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } else { + $options = []; if (!empty($this->options['hierarchy']) && $this->options['limit']) { - $options = []; - foreach ($vocabularies as $vocabulary) { $tree = $this->termStorage->loadTree($vocabulary->id(), 0, NULL, TRUE); if ($tree) { @@ -220,7 +220,6 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } else { - $options = []; $query = $this->termStorage->getQuery() // @todo Sorting on vocabulary properties - // https://www.drupal.org/node/1821274. @@ -268,11 +267,8 @@ protected function valueForm(&$form, FormStateInterface $form_state) { } } } - $form['value'] = [ + $form['value'] += [ '#type' => 'select', - '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @vocabs', [ - '@vocabs' => $vocabulary_labels, - ]) : $this->t('Select terms'), '#multiple' => TRUE, '#options' => $options, '#size' => min(9, count($options)),