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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 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.