function ActionAdminManageForm::buildForm

Same name in other branches
  1. 9 core/modules/action/src/Form/ActionAdminManageForm.php \Drupal\action\Form\ActionAdminManageForm::buildForm()
  2. 8.9.x core/modules/action/src/Form/ActionAdminManageForm.php \Drupal\action\Form\ActionAdminManageForm::buildForm()
  3. 11.x core/modules/action/src/Form/ActionAdminManageForm.php \Drupal\action\Form\ActionAdminManageForm::buildForm()

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) {
        $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;
}

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