public function SimpleAccessGroupBaseForm::form in Simple Access 8.3
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ SimpleAccessGroupBaseForm.php, line 34
Class
- SimpleAccessGroupBaseForm
- Provides group base form.
Namespace
Drupal\simple_access\FormCode
public function form(array $form, FormStateInterface $form_state) {
$group = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Name'),
'#default_value' => $group
->label(),
'#size' => 40,
'#maxlength' => 80,
'#description' => $this
->t('The name for the access group as it will appear on the content editing form.'),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $group
->id(),
'#machine_name' => [
'exists' => [
$this,
'exist',
],
],
'#disabled' => !$group
->isNew(),
];
if ($group
->id() != 'owner') {
$form['roles'] = [
'#type' => 'checkboxes',
'#title' => $this
->t('Roles'),
'#default_value' => $group->roles,
'#options' => user_role_names(),
'#description' => $this
->t('Roles that can view'),
];
$form['weight'] = [
'#type' => 'weight',
'#title' => $this
->t('Weight'),
'#default_value' => $group->weight,
'#delta' => 10,
'#description' => $this
->t('When setting permissions, heavier names will sink and lighter names will be positioned nearer the top.'),
];
}
return parent::form($form, $form_state);
}