You are here

public function YamlFormOptionsForm::reset in YAML Form 8

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/YamlFormOptionsForm.php, line 163

Class

YamlFormOptionsForm
Provides a form to set options.

Namespace

Drupal\yamlform

Code

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

  /** @var \Drupal\yamlform\YamlFormOptionsInterface $yamlform_options */
  $yamlform_options = $this
    ->getEntity();
  $yamlform_options
    ->set('options', '');
  $yamlform_options
    ->save();
  $this
    ->logger('yamlform')
    ->notice('Options @label have been reset.', [
    '@label' => $yamlform_options
      ->label(),
  ]);
  drupal_set_message($this
    ->t('Options %label have been reset.', [
    '%label' => $yamlform_options
      ->label(),
  ]));
  $form_state
    ->setRedirect('entity.yamlform_options.collection');
}