Commit 0c3dcb65 authored by seanpenn079's avatar seanpenn079 Committed by Rick Hawkins
Browse files

Issue #2895536 by seanB, Gravypower, tea.time, mikeker, davidbp: Allow...

Issue #2895536 by seanB, Gravypower, tea.time, mikeker, davidbp: Allow placeholder option for SearchAPI filters
parent a895fa2d
......@@ -3,9 +3,9 @@
namespace Drupal\better_exposed_filters\Plugin\views\exposed_form;
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
use Drupal\views\Plugin\views\exposed_form\InputRequired;
use Drupal\views\Plugin\views\filter\NumericFilter;
......@@ -523,7 +523,15 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
'#description' => $this->t('Places this element in the secondary options portion of the exposed form.'),
);
if ($filter instanceof StringFilter) {
$filter_form = array();
$form_state = new FormState();
/** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter */
$filter->buildExposedForm($filter_form, $form_state);
$supported_types = array('entity_autocomplete', 'textfield');
$filter_id = $filter->options['expose']['identifier'];
if (in_array($filter_form[$filter_id]['#type'], $supported_types) || in_array($filter_form[$filter_id]['value']['#type'], $supported_types)) {
// Allow users to specify placeholder text.
$bef_options[$label]['more_options']['placeholder_text'] = [
'#type' => 'textfield',
......@@ -893,7 +901,7 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
// Check for placeholder text.
if (!empty($settings[$label]['more_options']['placeholder_text'])) {
// @todo: Add token replacement for placeholder text.
$form[$label]['#placeholder'] = $settings[$label]['more_options']['placeholder_text'];
$form[$field_id]['#placeholder'] = $settings[$label]['more_options']['placeholder_text'];
}
// Handle filter value rewrites.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment