1 views_handler_filter_user_name.inc | views_handler_filter_user_name::value_form(&$form, &$form_state) |
Options form subform for setting options.
This should be overridden by all child classes and it must define $form['value']
Overrides views_handler_filter_in_operator::value_form
See also
options_form()
File
- core/
modules/ user/ views/ views_handler_filter_user_name.inc, line 15 - Definition of views_handler_filter_user_name.
Class
- views_handler_filter_user_name
- Filter handler for usernames.
Code
function value_form(&$form, &$form_state) {
$values = array();
if ($this->value) {
$result = db_query("SELECT * FROM {users} u WHERE uid IN (:uids)", array(':uids' => $this->value));
foreach ($result as $account) {
if ($account->uid) {
$values[] = $account->name;
}
else {
$values[] = 'Anonymous'; // Intentionally NOT translated.
}
}
}
sort($values);
$default_value = implode(', ', $values);
$form['value'] = array(
'#type' => 'textfield',
'#title' => t('Usernames'),
'#default_value' => $default_value,
'#autocomplete_path' => 'admin/views/ajax/autocomplete/user',
);
if (!empty($form_state['exposed']) && !isset($form_state['input'][$this->options['expose']['identifier']])) {
$form_state['input'][$this->options['expose']['identifier']] = $default_value;
}
if (empty($form_state['exposed'])) {
$form['value']['#description'] = t('Enter a comma separated list of user names.');
}
}