function user_filter_form
Form builder; Return form for user administration filters.
See also
Related topics
1 string reference to 'user_filter_form'
- user_admin in modules/
user/ user.admin.inc - Page callback: Generates the appropriate user administration form.
File
-
modules/
user/ user.admin.inc, line 49
Code
function user_filter_form() {
$session = isset($_SESSION['user_overview_filter']) ? $_SESSION['user_overview_filter'] : array();
$filters = user_filters();
$i = 0;
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Show only users where'),
'#theme' => 'exposed_filters__user',
);
foreach ($session as $filter) {
list($type, $value) = $filter;
if ($type == 'permission') {
// Merge arrays of module permissions into one.
// Slice past the first element '[any]' whose value is not an array.
$options = call_user_func_array('array_merge', array_values(array_slice($filters[$type]['options'], 1)));
$value = $options[$value];
}
else {
$value = $filters[$type]['options'][$value];
}
$t_args = array(
'%property' => $filters[$type]['title'],
'%value' => $value,
);
if ($i++) {
$form['filters']['current'][] = array(
'#markup' => t('and where %property is %value', $t_args),
);
}
else {
$form['filters']['current'][] = array(
'#markup' => t('%property is %value', $t_args),
);
}
}
$form['filters']['status'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'clearfix',
),
),
'#prefix' => $i ? '<div class="additional-filters">' . t('and where') . '</div>' : '',
);
$form['filters']['status']['filters'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'filters',
),
),
);
foreach ($filters as $key => $filter) {
$form['filters']['status']['filters'][$key] = array(
'#type' => 'select',
'#options' => $filter['options'],
'#title' => $filter['title'],
'#default_value' => '[any]',
);
}
$form['filters']['status']['actions'] = array(
'#type' => 'actions',
'#attributes' => array(
'class' => array(
'container-inline',
),
),
);
$form['filters']['status']['actions']['submit'] = array(
'#type' => 'submit',
'#value' => count($session) ? t('Refine') : t('Filter'),
);
if (count($session)) {
$form['filters']['status']['actions']['undo'] = array(
'#type' => 'submit',
'#value' => t('Undo'),
);
$form['filters']['status']['actions']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset'),
);
}
drupal_add_library('system', 'drupal.form');
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.