You are here

public function YamlFormSubmissionForm::autosave in YAML Form 8

Form submission handler to autosave when there are validation errors.

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/YamlFormSubmissionForm.php, line 676

Class

YamlFormSubmissionForm
Provides a form to collect and edit submissions.

Namespace

Drupal\yamlform

Code

public function autosave(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->hasAnyErrors()) {
    if ($this
      ->draftEnabled() && $this
      ->getYamlFormSetting('draft_auto_save') && !$this->entity
      ->isCompleted()) {
      $form_state
        ->setValue('in_draft', TRUE);
      $this
        ->submitForm($form, $form_state);
      $this
        ->save($form, $form_state);
      $this
        ->rebuild($form, $form_state);
    }
  }
}