You are here

public function ActionAdminManageForm::buildForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 57
Contains \Drupal\action\Form\ActionAdminManageForm.

Class

ActionAdminManageForm
Provides a configuration form for configurable actions.

Namespace

Drupal\action\Form

Code

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