You are here

protected function AutosaveButtonClickedTrait::isRestoreTriggered in Autosave Form 8

Checks if autosave restore has been triggered.

Parameters

array $form: The form array.

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

Return value

bool TRUE if autosave restore has been triggered, FALSE otherwise.

File

src/Form/AutosaveButtonClickedTrait.php, line 42

Class

AutosaveButtonClickedTrait

Namespace

Drupal\autosave_form\Form

Code

protected function isRestoreTriggered($form, FormStateInterface $form_state) {
  $input = $form_state
    ->getUserInput();

  // The restore submit is a non-ajax element and therefore its name will be
  // contained in the user input as a key.
  $triggered = isset($input[AutosaveFormInterface::AUTOSAVE_RESTORE_ELEMENT_NAME]);
  return $triggered;
}