function better_exposed_filters_exposed_form_plugin::options_form in Better Exposed Filters 6
Same name and namespace in other branches
- 6.3 better_exposed_filters_exposed_form_plugin.inc \better_exposed_filters_exposed_form_plugin::options_form()
- 7.3 better_exposed_filters_exposed_form_plugin.inc \better_exposed_filters_exposed_form_plugin::options_form()
- 7 better_exposed_filters_exposed_form_plugin.inc \better_exposed_filters_exposed_form_plugin::options_form()
Provide a form to edit options for this plugin.
Overrides views_plugin_exposed_form::options_form
File
- ./
better_exposed_filters_exposed_form_plugin.inc, line 22 - Provides an Better Exposed Filters exposed form plugin for View 3.x.
Class
- better_exposed_filters_exposed_form_plugin
- @file Provides an Better Exposed Filters exposed form plugin for View 3.x.
Code
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$bef_options = array();
/*
* Add options for exposed sorts
*/
$exposed = FALSE;
foreach ($this->display->handler
->get_handlers('sort') as $label => $sort) {
if ($sort->options['exposed']) {
$exposed = TRUE;
break;
}
}
if ($exposed) {
$bef_options['sort']['bef_format'] = array(
'#type' => 'select',
'#title' => t('Display exposed sort options as'),
'#default_value' => $this->options['bef']['sort']['bef_format'],
'#options' => array(
'default' => t('Default select list'),
'bef' => t('Radio Buttons'),
'bef_links' => t('Links'),
),
'#description' => t('Select a format for the exposed sort options.'),
);
$bef_options['sort']['combine'] = array(
'#type' => 'checkbox',
'#title' => t('Combine sort order with sort by'),
'#default_value' => $this->options['bef']['sort']['combine'],
'#description' => t('
Combines the sort by options and order (ascending or decending) into a single list. Use this to
display "Option1 (ascending)", "Option1 (descending)", "Option2 (ascending)", "Option2 (descending)"
in a single form element.
'),
);
$bef_options['sort']['reset'] = array(
'#type' => 'checkbox',
'#title' => t('Include a "Reset sort" option'),
'#default_value' => $this->options['bef']['sort']['reset'],
'#description' => t('Adds a "Reset sort" link; Views will use the default sort order.'),
);
$bef_options['sort']['reset_label'] = array(
'#type' => 'textfield',
'#title' => t('"Reset sort" label'),
'#default_value' => $this->options['bef']['sort']['reset_label'],
'#description' => t('Text to use if the above option is checked'),
);
}
/*
* Add options for exposed pager
*/
if ($this->display->display_options['pager'] && $this->display->display_options['pager']['options']['expose']['items_per_page']) {
$bef_options['pager']['bef_format'] = array(
'#type' => 'select',
'#title' => t('Display exposed pager options as'),
'#default_value' => $this->options['bef']['pager']['bef_format'],
'#options' => array(
'default' => t('Default select list'),
'bef' => t('Radio Buttons'),
'bef_links' => t('Links'),
),
'#description' => t('Select a format for the exposed pager options.'),
);
}
/*
* Changes to the options form need to be mirrored in hook_form_alter in
* better_exposed_filters.module to maintain Views 2.x support
*/
// Go through each filter and add the same options we used to add in hook_form_alter()
foreach ($this->display->handler
->get_handlers('filter') as $label => $filter) {
if (!$filter->options['exposed']) {
continue;
}
// Is this a type of field we can't tweak? (eg: text fields)
if ('=' == $filter->operator && !is_bool($filter->value)) {
// others?
continue;
}
// Main BEF option: default/checkboxes/hidden
$bef_options[$label]['bef_format'] = array(
'#type' => 'select',
'#title' => t('Display "@label" exposed filter as', array(
'@label' => $filter->options['expose']['label'],
)),
'#default_value' => $this->options['bef'][$label]['bef_format'],
'#options' => array(
'default' => t('Default select list'),
'bef' => t('Checkboxes/Radio Buttons'),
'bef_ul' => t('Nested Checkboxes/Radio Buttons'),
'bef_hidden' => t('Hidden'),
),
'#description' => t('Select a format for the exposed filter. The "Nested" option places
filter options is an unordered list. Hierarchical taxonomy filters
will be rendered as nested, unordered lists. "Links" will render filter
options as links, but may cause problems with AJAX views.
The "Hidden" option is
generally used for multi-step filters. Note: if "Force single"
is checked, radio buttons will be used. If "Force single" is
unchecked, checkboxes will be used.'),
);
// Link option is available if "Force single" is selected
// if ($filter->options['expose']['single']) {
//
// }
// Fieldset to keep the UI from getting out of hand
$bef_options[$label]['more_options'] = array(
'#type' => 'fieldset',
'#title' => t('More options for "@label"', array(
'@label' => $filter->options['expose']['label'],
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Select all checkbox
$bef_options[$label]['more_options']['bef_select_all_none'] = array(
'#type' => 'checkbox',
'#title' => t('Add select all/none links'),
'#default_value' => $this->options['bef'][$label]['more_options']['bef_select_all_none'],
'#disabled' => $filter->options['expose']['single'],
'#description' => t('Add a "Select All/None" link when rendering the exposed filter using
checkboxes. If this option is disabled, edit the filter and uncheck
"Force single". NOTE: The link is built at page load, so it will not appear
in the "Live Preview" which is loaded dynamically.'),
);
// Put filter in collapsible fieldset option
$bef_options[$label]['more_options']['bef_collapsible'] = array(
'#type' => 'checkbox',
'#title' => t('Make this filter collapsible'),
'#default_value' => $this->options['bef'][$label]['more_options']['bef_collapsible'],
'#description' => t('Puts this filter in a collapsible fieldset'),
);
// Build a description option form element
$bef_options[$label]['more_options']['bef_filter_description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $this->options['bef'][$label]['more_options']['bef_filter_description'],
'#description' => t('Adds descriptive text to the exposed filter. This is usually
rendered in smaller print under the label or the options.'),
);
}
// foreach ($filters as $filter) {
// Add BEF form elements to the exposed form options form
$form['bef'] = $bef_options;
}