You are here

function role_export_form_alter in Role Export 6

Same name and namespace in other branches
  1. 7 role_export.module \role_export_form_alter()

Implements hook_form_alter().

File

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

Code

function role_export_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_admin_new_role':

      // Add formatting to get the form element to show up correctly.
      drupal_add_css(drupal_get_path('module', 'role_export') . '/role_export.css');
      $form['name']['#description'] = t('The human-readable name of this role.<br />This text will be displayed as part of the list on the <em>Roles</em> page.');
      $form['machine_name'] = array(
        '#title' => t('Machine name'),
        '#type' => 'textfield',
        '#maxlength' => 255,
      );
      $form['#validate'][] = 'role_export_role_machine_name_validate';
      $form['#submit'][] = 'role_export_submit';
      break;
    case 'user_admin_role':
      $roles = role_export_roles();
      $form['machine_name'] = array(
        '#title' => t('Machine name'),
        '#type' => 'textfield',
        '#maxlength' => 255,
        '#default_value' => $roles[$form['rid']['#value']]->machine_name,
        // Role machine names can not be edited.
        '#disabled' => TRUE,
        '#weight' => -1,
      );
      $form['#submit'][] = 'role_export_submit';
      break;
  }
}