You are here

public function YamlFormSubmissionsPurgeForm::buildForm in YAML Form 8

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 YamlFormSubmissionsDeleteFormBase::buildForm

File

src/Form/YamlFormSubmissionsPurgeForm.php, line 51

Class

YamlFormSubmissionsPurgeForm
Form for form submission purge form.

Namespace

Drupal\yamlform\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $submission_total = \Drupal::entityQuery('yamlform_submission')
    ->count()
    ->execute();
  $form_total = \Drupal::entityQuery('yamlform')
    ->count()
    ->execute();
  $t_args = [
    '@submission_total' => $submission_total,
    '@submissions' => $this
      ->formatPlural($submission_total, $this
      ->t('submission'), $this
      ->t('submissions')),
    '@form_total' => $form_total,
    '@forms' => $this
      ->formatPlural($form_total, $this
      ->t('form'), $this
      ->t('forms')),
  ];
  $form['confirm'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Are you sure you want to delete @submission_total @submissions in @form_total @forms?', $t_args),
    '#required' => TRUE,
    '#weight' => -10,
  ];
  return $form;
}