function WorkflowAddForm::form

Gets the actual form array to be built.

Overrides EntityForm::form

File

core/modules/workflows/src/Form/WorkflowAddForm.php, line 48

Class

WorkflowAddForm
Form for adding workflows.

Namespace

Drupal\workflows\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  /** @var \Drupal\workflows\WorkflowInterface $workflow */
  $workflow = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $workflow->label(),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $workflow->id(),
    '#machine_name' => [
      'exists' => [
        Workflow::class,
        'load',
      ],
    ],
  ];
  $workflow_types = array_column($this->workflowTypePluginManager
    ->getDefinitions(), 'label', 'id');
  $form['workflow_type'] = [
    '#type' => 'select',
    '#title' => $this->t('Workflow type'),
    '#required' => TRUE,
    '#options' => $workflow_types,
  ];
  return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.