function NumericFilter::buildExposeForm
Same name in other branches
- 9 core/modules/views/src/Plugin/views/filter/NumericFilter.php \Drupal\views\Plugin\views\filter\NumericFilter::buildExposeForm()
- 8.9.x core/modules/views/src/Plugin/views/filter/NumericFilter.php \Drupal\views\Plugin\views\filter\NumericFilter::buildExposeForm()
- 11.x core/modules/views/src/Plugin/views/filter/NumericFilter.php \Drupal\views\Plugin\views\filter\NumericFilter::buildExposeForm()
Overrides FilterPluginBase::buildExposeForm
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ NumericFilter.php, line 49
Class
- NumericFilter
- Simple filter to handle greater than/less than filters.
Namespace
Drupal\views\Plugin\views\filterCode
public function buildExposeForm(&$form, FormStateInterface $form_state) {
parent::buildExposeForm($form, $form_state);
$form['expose']['min_placeholder'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['min_placeholder'],
'#title' => $this->t('Min placeholder'),
'#size' => 40,
'#description' => $this->t('Hint text that appears inside the Min field when empty.'),
];
$form['expose']['max_placeholder'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['max_placeholder'],
'#title' => $this->t('Max placeholder'),
'#size' => 40,
'#description' => $this->t('Hint text that appears inside the Max field when empty.'),
];
// Setup #states for all operators with two value.
$states = [
[
':input[name="options[expose][use_operator]"]' => [
'checked' => TRUE,
],
],
];
foreach ($this->operatorValues(2) as $operator) {
$states[] = [
':input[name="options[operator]"]' => [
'value' => $operator,
],
];
}
$form['expose']['min_placeholder']['#states']['visible'] = $states;
$form['expose']['max_placeholder']['#states']['visible'] = $states;
$form['expose']['placeholder'] = [
'#type' => 'textfield',
'#default_value' => $this->options['expose']['placeholder'],
'#title' => $this->t('Placeholder'),
'#size' => 40,
'#description' => $this->t('Hint text that appears inside the field when empty.'),
];
// Setup #states for all operators with one value.
$form['expose']['placeholder']['#states']['visible'] = [
[
':input[name="options[expose][use_operator]"]' => [
'checked' => TRUE,
],
],
];
foreach ($this->operatorValues(1) as $operator) {
$form['expose']['placeholder']['#states']['visible'][] = [
':input[name="options[operator]"]' => [
'value' => $operator,
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.