public RoleForm::form(array $form, FormStateInterface $form_state)
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 16
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);
}
Please login to continue.