function RoleForm::form
Same name in other branches
- 8.9.x core/modules/user/src/RoleForm.php \Drupal\user\RoleForm::form()
- 10 core/modules/user/src/RoleForm.php \Drupal\user\RoleForm::form()
- 11.x core/modules/user/src/RoleForm.php \Drupal\user\RoleForm::form()
Overrides EntityForm::form
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.