You are here

function role_export_role_machine_name_validate in Role Export 6

Ensure the machine_name of the new role is valid and doesn't already exist.

1 string reference to 'role_export_role_machine_name_validate'
role_export_form_alter in ./role_export.module
Implements hook_form_alter().

File

./role_export.module, line 69
Role Export's primary module file.

Code

function role_export_role_machine_name_validate($form, &$form_state) {
  $value = $form_state['values']['machine_name'];
  if ($value !== role_export_machine_name_gen($value)) {
    form_set_error('machine_name', t("That's not a valid machine name.  Please use only lowercase letters a–z, numbers 0–9, and underscore."));
  }
  foreach (role_export_roles() as $role) {
    if ($role->machine_name == $value) {
      form_set_error('machine_name', t('The machine_name you\'ve currently entered is already taken, but it must be unique. Please enter in a new machine_name.'));
    }
  }
}