public function SimpleAccessProfileBaseForm::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/ SimpleAccessProfileBaseForm.php, line 34
Class
- SimpleAccessProfileBaseForm
- Provides Profile base form.
Namespace
Drupal\simple_access\FormCode
public function form(array $form, FormStateInterface $form_state) {
/** @var \Drupal\simple_access\Entity\SimpleAccessProfile $profile */
$profile = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Name'),
'#default_value' => $profile
->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' => $profile
->id(),
'#machine_name' => [
'exists' => [
$this,
'exist',
],
],
'#disabled' => !$profile
->isNew(),
];
$form['access'] = [
'#type' => 'simple_access_groups',
'#default_value' => $profile->access,
'#override_privilege' => TRUE,
];
$form['weight'] = [
'#type' => 'weight',
'#title' => $this
->t('Weight'),
'#default_value' => $profile->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);
}