function user_admin_role

Form to configure a single role.

See also

user_admin_role_submit()

Related topics

1 call to user_admin_role()
user_admin_roles in drupal/core/modules/user/user.admin.inc
Form to re-order roles or add a new one.
2 string references to 'user_admin_role'
UserRoleUpgradePathTest::testRoleUpgrade in drupal/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserRoleUpgradePathTest.php
Tests expected role ID conversions after a successful upgrade.
user_menu in drupal/core/modules/user/user.module
Implements hook_menu().

File

drupal/core/modules/user/user.admin.inc, line 945
Admin page callback file for the user module.

Code

function user_admin_role($form, $form_state, $role) {
  $form['role'] = array(
    '#tree' => TRUE,
    '#parents' => array(
      'role',
    ),
  );
  $form['role']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Role name'),
    '#default_value' => $role->name,
    '#size' => 30,
    '#required' => TRUE,
    '#maxlength' => 64,
    '#description' => t('The name for this role. Example: "Moderator", "Editorial board", "Site architect".'),
  );
  $form['role']['rid'] = array(
    '#type' => 'machine_name',
    '#default_value' => $role->rid,
    '#required' => TRUE,
    '#disabled' => !empty($role->rid),
    '#size' => 30,
    '#maxlength' => 64,
    '#machine_name' => array(
      'exists' => 'user_role_load',
      'source' => array(
        'role',
        'name',
      ),
    ),
  );
  $form['role']['weight'] = array(
    '#type' => 'value',
    '#value' => $role->weight,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => !empty($role->rid) ? t('Save role') : t('Add role'),
  );
  $form['actions']['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete role'),
    '#access' => !empty($role->rid) && !in_array($role->rid, array(
      DRUPAL_ANONYMOUS_RID,
      DRUPAL_AUTHENTICATED_RID,
    )),
    '#submit' => array(
      'user_admin_role_delete_submit',
    ),
  );
  return $form;
}