1 views_handler_filter.inc | views_handler_filter::expose_form(&$form, &$form_state) |
Options form subform for exposed filter options.
Overrides views_handler::expose_form
See also
options_form()
File
- core/
modules/ views/ handlers/ views_handler_filter.inc, line 475 - @todo.
Class
- views_handler_filter
- Base class for filters.
Code
function expose_form(&$form, &$form_state) {
$form['#theme'] = 'views_ui_expose_filter_form';
// #flatten will move everything from $form['expose'][$key] to $form[$key]
// prior to rendering. That's why the pre_render for it needs to run first,
// so that when the next pre_render (the one for fieldsets) runs, it gets
// the flattened data.
array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data');
$form['expose']['#flatten'] = TRUE;
if (empty($this->always_required)) {
$form['expose']['required'] = array(
'#type' => 'checkbox',
'#title' => t('Required'),
'#default_value' => $this->options['expose']['required'],
);
}
else {
$form['expose']['required'] = array(
'#type' => 'value',
'#value' => TRUE,
);
}
$form['expose']['label'] = array(
'#type' => 'textfield',
'#default_value' => $this->options['expose']['label'],
'#title' => t('Label'),
'#size' => 40,
);
$form['expose']['description'] = array(
'#type' => 'textfield',
'#default_value' => $this->options['expose']['description'],
'#title' => t('Description'),
'#size' => 60,
);
if (!empty($form['operator']['#type'])) {
// Increase the width of the left (operator) column.
$form['operator']['#prefix'] = '<div class="views-group-box views-left-40">';
$form['operator']['#suffix'] = '</div>';
$form['value']['#prefix'] = '<div class="views-group-box views-right-60">';
$form['value']['#suffix'] = '</div>';
$form['expose']['use_operator'] = array(
'#type' => 'checkbox',
'#title' => t('Expose operator'),
'#description' => t('Allow the user to choose the operator.'),
'#default_value' => !empty($this->options['expose']['use_operator']),
);
$form['expose']['operator_id'] = array(
'#type' => 'textfield',
'#default_value' => $this->options['expose']['operator_id'],
'#title' => t('Operator identifier'),
'#size' => 40,
'#description' => t('This will appear in the URL after the ? to identify this operator.'),
'#states' => array(
'visible' => array(
':input[name="options[expose][use_operator]"]' => array('checked' => TRUE),
),
),
'#fieldset' => 'more',
);
}
else {
$form['expose']['operator_id'] = array(
'#type' => 'value',
'#value' => '',
);
}
if (empty($this->always_multiple)) {
$form['expose']['multiple'] = array(
'#type' => 'checkbox',
'#title' => t('Allow multiple selections'),
'#description' => t('Enable to allow users to select multiple items.'),
'#default_value' => $this->options['expose']['multiple'],
);
}
$form['expose']['remember'] = array(
'#type' => 'checkbox',
'#title' => t('Remember the last selection'),
'#description' => t('Enable to remember the last selection made by the user.'),
'#default_value' => $this->options['expose']['remember'],
);
$role_options = array_map('check_plain', user_roles());
$form['expose']['remember_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('User roles'),
'#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'),
'#default_value' => $this->options['expose']['remember_roles'],
'#options' => $role_options,
'#states' => array(
'invisible' => array(
':input[name="options[expose][remember]"]' => array('checked' => FALSE),
),
),
);
$form['expose']['identifier'] = array(
'#type' => 'textfield',
'#default_value' => $this->options['expose']['identifier'],
'#title' => t('Filter identifier'),
'#size' => 40,
'#description' => t('This will appear in the URL after the ? to identify this filter. Cannot be blank.'),
'#fieldset' => 'more',
);
}