public function FilterPluginBase::showExposeButton in Views (for Drupal 7) 8.3
Shortcut to display the expose/hide button.
Overrides HandlerBase::showExposeButton
1 call to FilterPluginBase::showExposeButton()
- FilterPluginBase::buildOptionsForm in lib/
Drupal/ views/ Plugin/ views/ filter/ FilterPluginBase.php - Provide the basic form which calls through to subforms. If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.
File
- lib/
Drupal/ views/ Plugin/ views/ filter/ FilterPluginBase.php, line 415 - Definition of Drupal\views\Plugin\views\filter\FilterPluginBase.
Class
- FilterPluginBase
- Base class for filters.
Namespace
Drupal\views\Plugin\views\filterCode
public function showExposeButton(&$form, &$form_state) {
$form['expose_button'] = array(
'#prefix' => '<div class="views-expose clearfix">',
'#suffix' => '</div>',
// Should always come after the description and the relationship.
'#weight' => -200,
);
// Add a checkbox for JS users, which will have behavior attached to it
// so it can replace the button.
$form['expose_button']['checkbox'] = array(
'#theme_wrappers' => array(
'container',
),
'#attributes' => array(
'class' => array(
'js-only',
),
),
);
$form['expose_button']['checkbox']['checkbox'] = array(
'#title' => t('Expose this filter to visitors, to allow them to change it'),
'#type' => 'checkbox',
);
// Then add the button itself.
if (empty($this->options['exposed'])) {
$form['expose_button']['markup'] = array(
'#markup' => '<div class="description exposed-description">' . t('This filter is not exposed. Expose it to allow the users to change it.') . '</div>',
);
$form['expose_button']['button'] = array(
'#limit_validation_errors' => array(),
'#type' => 'submit',
'#value' => t('Expose filter'),
'#submit' => array(
'views_ui_config_item_form_expose',
),
);
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
}
else {
$form['expose_button']['markup'] = array(
'#markup' => '<div class="description exposed-description">' . t('This filter is exposed. If you hide it, users will not be able to change it.') . '</div>',
);
$form['expose_button']['button'] = array(
'#limit_validation_errors' => array(),
'#type' => 'submit',
'#value' => t('Hide filter'),
'#submit' => array(
'views_ui_config_item_form_expose',
),
);
$form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
}
}