You are here

public function PurgerMoveForm::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/PurgerMoveForm.php, line 80

Class

PurgerMoveForm
Move purger {id} in the purger execution order - 'up' or 'down'.

Namespace

Drupal\purge_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $this->definition = $form_state
    ->getBuildInfo()['args'][0]['definition'];
  $this->direction = $form_state
    ->getBuildInfo()['args'][0]['direction'];
  $this->id = $form_state
    ->getBuildInfo()['args'][0]['id'];
  $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' => '::movePurger',
    ],
  ];
  $form['actions']['cancel'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('No'),
    '#weight' => -10,
    '#ajax' => [
      'callback' => '::closeDialog',
    ],
  ];
  return $form;
}