public function FormsStepsAddForm::form in Forms Steps 8
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/ FormsStepsAddForm.php, line 22
Class
- FormsStepsAddForm
- Provides a form to add a Forms Steps.
Namespace
Drupal\forms_steps\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form['settings'] = [
'#type' => 'details',
'#title' => $this
->t('Settings'),
'#open' => $this->entity
->isNew(),
];
$form['settings']['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#default_value' => $this->entity
->label(),
'#required' => TRUE,
];
$form['settings']['id'] = [
'#type' => 'machine_name',
'#description' => $this
->t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
'#disabled' => !$this->entity
->isNew(),
'#default_value' => $this->entity
->id(),
'#machine_name' => [
'exists' => [
$this,
'exists',
],
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
'source' => [
'settings',
'label',
],
'error' => $this
->t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'),
],
];
$form['settings']['description'] = [
'#type' => 'textarea',
'#default_value' => $this->entity
->getDescription(),
'#description' => $this
->t('Enter a description for this Forms Steps.'),
'#title' => $this
->t('Description'),
];
return parent::form($form, $form_state);
}