Commit 09337173 authored by vaibhavjain's avatar vaibhavjain Committed by Mike Keran
Browse files

Issue #2880307 by vaibhavjain, PapaGrande: Allow Textfields to be excluded from AutoSubmit

parent af2ea854
......@@ -12,6 +12,9 @@ better_exposed_filters.general:
autosubmit:
type: boolean
label: 'Autosubmit'
autosubmit_exclude_textfield:
type: boolean
label: 'Exclude Textfield'
autosubmit_hide:
type: boolean
label: 'Hide submit button'
......
......@@ -88,6 +88,18 @@ class BetterExposedFilters extends InputRequired {
'#default_value' => $existing['general']['autosubmit'],
);
$bef_options['general']['autosubmit_exclude_textfield'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Exclude Textfield'),
'#description' => $this->t('Exclude Textfield from autosubmit. User will have to press enter key or click submit.'),
'#default_value' => $existing['general']['autosubmit_exclude_textfield'],
'#states' => array(
'visible' => array(
':input[name="exposed_form_options[bef][general][autosubmit]"]' => array('checked' => TRUE),
),
),
);
$bef_options['general']['autosubmit_hide'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Hide submit button'),
......@@ -644,6 +656,14 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
$form['actions']['submit']['#attributes']['data-bef-auto-submit-click'] = '';
$form['#attached']['library'][] = 'better_exposed_filters/auto_submit';
if (!empty($settings['general']['autosubmit_exclude_textfield'])) {
foreach ($form as &$element) {
if (isset($element['#type']) && $element['#type'] == 'textfield') {
$element['#attributes'] = ['data-bef-auto-submit-exclude' => ''];
}
}
}
if (!empty($settings['general']['autosubmit_hide'])) {
$form['actions']['submit']['#attributes']['class'][] = 'js-hide';
}
......@@ -1471,6 +1491,7 @@ Title Desc|Z -> A</pre> Leave the replacement text blank to remove an option alt
'allow_secondary' => FALSE,
'secondary_label' => $this->t('Advanced options'),
'autosubmit' => FALSE,
'autosubmit_exclude_textfield' => FALSE,
'autosubmit_hide' => FALSE,
),
'sort' => array(
......
Supports Markdown
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