You are here

public function DeleteConfigForm::buildForm in Demonstration site (Sandbox / Snapshot) 8

form to delete config snapshots.

Overrides FormInterface::buildForm

File

src/Form/DeleteConfigForm.php, line 23

Class

DeleteConfigForm
Handles the deletion of config sanpshots

Namespace

Drupal\demo\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['dump'] = demo_get_config_dumps();
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['delete'] = [
    '#type' => 'submit',
    '#value' => t('Delete'),
    '#submit' => [
      'demo_config_delete_submit',
    ],
  ];

  // If there are no snapshots yet, hide the selection and form actions.
  if (empty($form['dump']['#options'])) {
    $form['dump']['#access'] = FALSE;
    $form['actions']['#access'] = FALSE;
  }
  return $form;
}