public function RoleFormController::form

Returns the actual form array to be built.

Overrides EntityFormController::form

See also

Drupal\Core\Entity\EntityFormController::build()

File

drupal/core/modules/user/lib/Drupal/user/RoleFormController.php, line 21
Contains \Drupal\user\RoleFormController.

Class

RoleFormController
Form controller for the role entity edit forms.

Namespace

Drupal\user

Code

public function form(array $form, array &$form_state) {
  $entity = $this->entity;
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Role name'),
    '#default_value' => $entity
      ->label(),
    '#size' => 30,
    '#required' => TRUE,
    '#maxlength' => 64,
    '#description' => t('The name for this role. Example: "Moderator", "Editorial board", "Site architect".'),
  );
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $entity
      ->id(),
    '#required' => TRUE,
    '#disabled' => !$entity
      ->isNew(),
    '#size' => 30,
    '#maxlength' => 64,
    '#machine_name' => array(
      'exists' => 'user_role_load',
    ),
  );
  $form['weight'] = array(
    '#type' => 'value',
    '#value' => $entity
      ->get('weight'),
  );
  return parent::form($form, $form_state, $entity);
}