public function Autosubmit::exposedFormAlter in Brainstorm profile 8
Alters the exposed form.
The exposed form is built by calling the renderExposedForm() method on this class, and then letting each exposed filter and sort handler add widgets to the form. After that is finished, this method is called to let the class alter the finished form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ExposedFormPluginBase::exposedFormAlter
See also
\Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface::renderExposedForm()
\Drupal\views\Form\ViewsExposedForm::buildForm()
File
- module/
custom/ views_filter_autosubmit/ src/ Plugin/ views/ exposed_form/ Autosubmit.php, line 49
Class
- Autosubmit
- Extends the exposed form to provide an autosubmit functionality.
Namespace
Drupal\views_filter_autosubmit\Plugin\views\exposed_formCode
public function exposedFormAlter(&$form, FormStateInterface $form_state) {
// Apply autosubmit values.
$form = array_merge_recursive($form, [
'#attributes' => [
'class' => [
'views-auto-submit-full-form',
],
],
]);
$form['actions']['submit']['#attributes']['class'][] = 'views-use-ajax';
$form['actions']['submit']['#attributes']['class'][] = 'views-auto-submit-click';
$form['#attached']['library'][] = 'views_filter_autosubmit/autosubmit';
if (!empty($this->options['autosubmit_hide'])) {
$form['actions']['submit']['#attributes']['class'][] = 'js-hide';
}
}