function ConfigDeleteForm::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

src/Form/ConfigDeleteForm.php, line 26

Class

ConfigDeleteForm
Edit config variable form.

Namespace

Drupal\devel\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, $config_name = '') {
  $config = $this->config($config_name);
  if ($config === FALSE || $config->isNew()) {
    $this->messenger()
      ->addError($this->t('Config @name does not exist in the system.', [
      '@name' => $config_name,
    ]));
    return;
  }
  $form['#title'] = $this->getQuestion();
  $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['name'] = [
    '#type' => 'value',
    '#value' => $config_name,
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this->getConfirmText(),
    '#submit' => [
      [
        $this,
        'submitForm',
      ],
    ],
  ];
  $form['actions']['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this->getRequest());
  return $form;
}