function ConfigDeleteForm::buildForm
Same name in other branches
- 5.x src/Form/ConfigDeleteForm.php \Drupal\devel\Form\ConfigDeleteForm::buildForm()
Overrides FormInterface::buildForm
File
-
src/
Form/ ConfigDeleteForm.php, line 26
Class
- ConfigDeleteForm
- Edit config variable form.
Namespace
Drupal\devel\FormCode
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;
}