function user_admin_role_validate
Form validation handler for the user_admin_role() form.
1 string reference to 'user_admin_role_validate'
- user_admin_roles in modules/
user/ user.admin.inc - Form to re-order roles or add a new one.
File
-
modules/
user/ user.admin.inc, line 1007
Code
function user_admin_role_validate($form, &$form_state) {
if (!empty($form_state['values']['name'])) {
if ($form_state['values']['op'] == t('Save role')) {
$role = user_role_load_by_name($form_state['values']['name']);
if ($role && $role->rid != $form_state['values']['rid']) {
form_set_error('name', t('The role name %name already exists. Choose another role name.', array(
'%name' => $form_state['values']['name'],
)));
}
}
elseif ($form_state['values']['op'] == t('Add role')) {
if (user_role_load_by_name($form_state['values']['name'])) {
form_set_error('name', t('The role name %name already exists. Choose another role name.', array(
'%name' => $form_state['values']['name'],
)));
}
}
}
else {
form_set_error('name', t('You must specify a valid role name.'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.