Loading CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3293474 by admirlju, jhedstrom, drunken monkey: Added configurable maximum length for exposed Views fulltext filter. Search API 1.30 (2023-10-15): ----------------------------- Loading config/schema/search_api.views.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -287,6 +287,9 @@ views.filter.search_api_fulltext: searched_fields_id: type: string label: 'Searched fields identifier' value_maxlength: type: integer label: 'Search field character limit' views.filter.search_api_language: type: views.filter.language Loading src/Plugin/views/filter/SearchApiFulltext.php +16 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ class SearchApiFulltext extends FilterPluginBase { $options['expose']['contains']['placeholder'] = ['default' => '']; $options['expose']['contains']['expose_fields'] = ['default' => FALSE]; $options['expose']['contains']['searched_fields_id'] = ['default' => '']; $options['expose']['contains']['value_maxlength'] = ['default' => 128]; return $options; } Loading Loading @@ -223,6 +224,14 @@ class SearchApiFulltext extends FilterPluginBase { '#description' => $this->t('Hint text that appears inside the field when empty.'), ]; $form['expose']['value_maxlength'] = [ '#title' => $this->t('Search field character limit'), '#description' => $this->t('Maximum number of characters to allow as keywords input.'), '#type' => 'number', '#min' => 1, '#default_value' => $this->options['expose']['value_maxlength'], ]; $form['expose']['expose_fields'] = [ '#type' => 'checkbox', '#default_value' => $this->options['expose']['expose_fields'], Loading Loading @@ -282,11 +291,17 @@ class SearchApiFulltext extends FilterPluginBase { protected function valueForm(&$form, FormStateInterface $form_state) { parent::valueForm($form, $form_state); $exposed = (bool) $form_state->get('exposed'); $max_length = NULL; if ($exposed && $this->options['expose']['value_maxlength']) { $max_length = $this->options['expose']['value_maxlength']; } $form['value'] = [ '#type' => 'textfield', '#title' => !$form_state->get('exposed') ? $this->t('Value') : '', '#title' => !$exposed ? $this->t('Value') : '', '#size' => 30, '#default_value' => $this->value, '#maxlength' => $max_length, ]; if (!empty($this->options['expose']['placeholder'])) { $form['value']['#attributes']['placeholder'] = $this->options['expose']['placeholder']; Loading Loading
CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Search API 1.x, dev (xxxx-xx-xx): --------------------------------- - #3293474 by admirlju, jhedstrom, drunken monkey: Added configurable maximum length for exposed Views fulltext filter. Search API 1.30 (2023-10-15): ----------------------------- Loading
config/schema/search_api.views.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -287,6 +287,9 @@ views.filter.search_api_fulltext: searched_fields_id: type: string label: 'Searched fields identifier' value_maxlength: type: integer label: 'Search field character limit' views.filter.search_api_language: type: views.filter.language Loading
src/Plugin/views/filter/SearchApiFulltext.php +16 −1 Original line number Diff line number Diff line Loading @@ -136,6 +136,7 @@ class SearchApiFulltext extends FilterPluginBase { $options['expose']['contains']['placeholder'] = ['default' => '']; $options['expose']['contains']['expose_fields'] = ['default' => FALSE]; $options['expose']['contains']['searched_fields_id'] = ['default' => '']; $options['expose']['contains']['value_maxlength'] = ['default' => 128]; return $options; } Loading Loading @@ -223,6 +224,14 @@ class SearchApiFulltext extends FilterPluginBase { '#description' => $this->t('Hint text that appears inside the field when empty.'), ]; $form['expose']['value_maxlength'] = [ '#title' => $this->t('Search field character limit'), '#description' => $this->t('Maximum number of characters to allow as keywords input.'), '#type' => 'number', '#min' => 1, '#default_value' => $this->options['expose']['value_maxlength'], ]; $form['expose']['expose_fields'] = [ '#type' => 'checkbox', '#default_value' => $this->options['expose']['expose_fields'], Loading Loading @@ -282,11 +291,17 @@ class SearchApiFulltext extends FilterPluginBase { protected function valueForm(&$form, FormStateInterface $form_state) { parent::valueForm($form, $form_state); $exposed = (bool) $form_state->get('exposed'); $max_length = NULL; if ($exposed && $this->options['expose']['value_maxlength']) { $max_length = $this->options['expose']['value_maxlength']; } $form['value'] = [ '#type' => 'textfield', '#title' => !$form_state->get('exposed') ? $this->t('Value') : '', '#title' => !$exposed ? $this->t('Value') : '', '#size' => 30, '#default_value' => $this->value, '#maxlength' => $max_length, ]; if (!empty($this->options['expose']['placeholder'])) { $form['value']['#attributes']['placeholder'] = $this->options['expose']['placeholder']; Loading