You are here

public function ActionAdminManageForm::buildForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/action/src/Form/ActionAdminManageForm.php \Drupal\action\Form\ActionAdminManageForm::buildForm()
  2. 9 core/modules/action/src/Form/ActionAdminManageForm.php \Drupal\action\Form\ActionAdminManageForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

core/modules/action/src/Form/ActionAdminManageForm.php, line 53

Class

ActionAdminManageForm
Provides a configuration form for configurable actions.

Namespace

Drupal\action\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $actions = [];
  foreach ($this->manager
    ->getDefinitions() as $id => $definition) {
    if (is_subclass_of($definition['class'], '\\Drupal\\Core\\Plugin\\PluginFormInterface')) {
      $actions[$id] = $definition['label'];
    }
  }
  asort($actions);
  $form['parent'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Create an advanced action'),
    '#attributes' => [
      'class' => [
        'container-inline',
      ],
    ],
    '#open' => TRUE,
  ];
  $form['parent']['action'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Action'),
    '#title_display' => 'invisible',
    '#options' => $actions,
    '#empty_option' => $this
      ->t('- Select -'),
  ];
  $form['parent']['actions'] = [
    '#type' => 'actions',
  ];
  $form['parent']['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Create'),
  ];
  return $form;
}