You are here

public function RequiredContextDelete::buildForm in Chaos Tool Suite (ctools) 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

src/Form/RequiredContextDelete.php, line 61

Class

RequiredContextDelete
Base class for adding a required contexts step to your wizard.

Namespace

Drupal\ctools\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $id = NULL, $tempstore_id = NULL, $machine_name = NULL) {
  $this->tempstore_id = $tempstore_id;
  $this->machine_name = $machine_name;
  $this->id = $id;
  $cached_values = $this->tempstore
    ->get($this->tempstore_id)
    ->get($this->machine_name);
  $form['#title'] = $this
    ->getQuestion($id, $cached_values);
  $form['#attributes']['class'][] = 'confirmation';
  $form['description'] = [
    '#markup' => $this
      ->getDescription(),
  ];
  $form[$this
    ->getFormName()] = [
    '#type' => 'hidden',
    '#value' => 1,
  ];

  // By default, render the form using theme_confirm_form().
  if (!isset($form['#theme'])) {
    $form['#theme'] = 'confirm_form';
  }
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions'] += $this
    ->actions($form, $form_state);
  return $form;
}