You are here

public function QueuerDeleteForm::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 ConfirmFormBase::buildForm

File

modules/purge_ui/src/Form/QueuerDeleteForm.php, line 66

Class

QueuerDeleteForm
Delete queuer {id}.

Namespace

Drupal\purge_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this->queuer = $this->purgeQueuers
    ->get($form_state
    ->getBuildInfo()['args'][0]);
  $form = parent::buildForm($form, $form_state);

  // This is rendered as a modal dialog, so we need to set some extras.
  $form['#attached']['library'][] = 'core/drupal.dialog.ajax';

  // Update the buttons and bind callbacks.
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#button_type' => 'primary',
    '#value' => $this
      ->getConfirmText(),
    '#ajax' => [
      'callback' => '::deleteQueuer',
    ],
  ];
  $form['actions']['cancel'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('No'),
    '#weight' => -10,
    '#ajax' => [
      'callback' => '::closeDialog',
    ],
  ];
  return $form;
}