You are here

public function WebformOptionsForm::reset in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformOptionsForm.php \Drupal\webform\WebformOptionsForm::reset()

Reset options.

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/WebformOptionsForm.php, line 242

Class

WebformOptionsForm
Provides a form to set options.

Namespace

Drupal\webform

Code

public function reset(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\webform\WebformOptionsInterface $webform_options */
  $webform_options = $this
    ->getEntity();
  $webform_options
    ->set('options', '');
  $webform_options
    ->save();
  $context = [
    '@label' => $webform_options
      ->label(),
    'link' => $webform_options
      ->toLink($this
      ->t('Edit'), 'edit-form')
      ->toString(),
  ];
  $this
    ->logger('webform')
    ->notice('Options @label have been reset.', $context);
  $this
    ->messenger()
    ->addStatus($this
    ->t('Options %label have been reset.', [
    '%label' => $webform_options
      ->label(),
  ]));
  $form_state
    ->setRedirect('entity.webform_options.collection');
}