public function RoleForm::form in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/src/RoleForm.php \Drupal\user\RoleForm::form()
- 9 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 18
Class
- RoleForm
- Form controller for the role entity edit forms.
Namespace
Drupal\userCode
public function form(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$form['label'] = [
'#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'] = [
'#type' => 'machine_name',
'#default_value' => $entity
->id(),
'#required' => TRUE,
'#disabled' => !$entity
->isNew(),
'#size' => 30,
'#maxlength' => 64,
'#machine_name' => [
'exists' => [
'\\Drupal\\user\\Entity\\Role',
'load',
],
],
];
$form['weight'] = [
'#type' => 'value',
'#value' => $entity
->getWeight(),
];
return parent::form($form, $form_state, $entity);
}