function ctools_context_user_settings_form_validate
Validate a user.
File
-
plugins/
contexts/ user.inc, line 118
Code
function ctools_context_user_settings_form_validate($form, &$form_state) {
if ($form_state['values']['type'] != 'select') {
return;
}
// Validate the autocomplete.
if (empty($form_state['values']['uid']) && empty($form_state['values']['user'])) {
form_error($form['user'], t('You must select a user.'));
return;
}
if (empty($form_state['values']['user'])) {
return;
}
$account = user_load_by_name($form_state['values']['user']);
if (!$account) {
form_error($form['user'], t('Invalid user selected.'));
}
else {
form_set_value($form['uid'], $account->uid, $form_state);
}
}