You are here

public function RoleForm::form in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/RoleForm.php \Drupal\user\RoleForm::form()

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

core/modules/user/src/RoleForm.php, line 21
Contains \Drupal\user\RoleForm.

Class

RoleForm
Form controller for the role entity edit forms.

Namespace

Drupal\user

Code

public function form(array $form, FormStateInterface $form_state) {
  $entity = $this->entity;
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Role name'),
    '#default_value' => $entity
      ->label(),
    '#size' => 30,
    '#required' => TRUE,
    '#maxlength' => 64,
    '#description' => $this
      ->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' => [
        '\\Drupal\\user\\Entity\\Role',
        'load',
      ],
    ),
  );
  $form['weight'] = array(
    '#type' => 'value',
    '#value' => $entity
      ->getWeight(),
  );
  return parent::form($form, $form_state, $entity);
}