You are here

public function WebformResultsCustomForm::delete in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Form/WebformResultsCustomForm.php \Drupal\webform\Form\WebformResultsCustomForm::delete()

Webform delete customized columns handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Form/WebformResultsCustomForm.php, line 453

Class

WebformResultsCustomForm
Webform for webform results custom(ize) webform.

Namespace

Drupal\webform\Form

Code

public function delete(array &$form, FormStateInterface $form_state) {
  foreach ($this->names as $name) {
    $this
      ->deleteData($name);
  }
  if ($this->customize) {
    if ($this->type === static::CUSTOMIZE_USER) {
      $this
        ->messenger()
        ->addStatus($this
        ->t('Your customized table has been reset.'));
    }
    else {
      $this
        ->messenger()
        ->addStatus($this
        ->t('The default customized table has been reset.'));
    }
  }
  else {
    $this
      ->messenger()
      ->addStatus($this
      ->t('The customized table has been reset.'));
  }

  // Set redirect.
  $redirect_url = $this->requestHandler
    ->getUrl($this->webform, $this->sourceEntity, 'webform.results_submissions');
  $form_state
    ->setRedirectUrl($redirect_url);
}