You are here

public function PluginDetailsForm::buildForm in Purge 8.3

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

modules/purge_ui/src/Form/PluginDetailsForm.php, line 31

Class

PluginDetailsForm
Render plugin details.

Namespace

Drupal\purge_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['description'] = [
    '#prefix' => '<h3>',
    '#markup' => $form_state
      ->getBuildInfo()['args'][0]['details'],
    '#suffix' => '</h3>',
  ];

  // Set dialog code and add the close button.
  $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['close'] = [
    '#type' => 'submit',
    '#button_type' => 'primary',
    '#value' => $this
      ->t('Close'),
    '#weight' => -10,
    '#ajax' => [
      'callback' => '::closeDialog',
    ],
  ];
  return $form;
}