You are here

protected function AutosaveButtonClickedTrait::isRejectTriggered 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 61

Class

AutosaveButtonClickedTrait

Namespace

Drupal\autosave_form\Form

Code

protected function isRejectTriggered($form, FormStateInterface $form_state) {
  $user_input = $form_state
    ->getUserInput();

  // The reject submit is an ajax element and therefore its name will not be
  // contained in the user input as a key, but will be contained as a value
  // under the key "_triggering_element_name".
  $triggered = isset($user_input['_triggering_element_name']) && $user_input['_triggering_element_name'] == AutosaveFormInterface::AUTOSAVE_REJECT_ELEMENT_NAME;
  return $triggered;
}