You are here

public function ActionFormBase::form in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/action/src/Form/ActionFormBase.php \Drupal\action\Form\ActionFormBase::form()

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/action/src/Form/ActionFormBase.php, line 52

Class

ActionFormBase
Provides a base form for action forms.

Namespace

Drupal\action\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#default_value' => $this->entity
      ->label(),
    '#maxlength' => '255',
    '#description' => $this
      ->t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'),
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $this->entity
      ->id(),
    '#disabled' => !$this->entity
      ->isNew(),
    '#maxlength' => 64,
    '#description' => $this
      ->t('A unique name for this action. It must only contain lowercase letters, numbers and underscores.'),
    '#machine_name' => [
      'exists' => [
        $this,
        'exists',
      ],
    ],
  ];
  $form['plugin'] = [
    '#type' => 'value',
    '#value' => $this->entity
      ->get('plugin'),
  ];
  $form['type'] = [
    '#type' => 'value',
    '#value' => $this->entity
      ->getType(),
  ];
  if ($plugin = $this
    ->getPlugin()) {
    $form += $plugin
      ->buildConfigurationForm($form, $form_state);
  }
  return parent::form($form, $form_state);
}