public function AutosaveFormAlterTrait::autosaveFormRestoreSubmit in Autosave Form 8
Form submission handler for restoring autosaved state.
File
- src/
Form/ AutosaveFormAlterTrait.php, line 121
Class
- AutosaveFormAlterTrait
- Provides a trait for common autosave form alterations.
Namespace
Drupal\autosave_form\FormCode
public function autosaveFormRestoreSubmit($form, FormStateInterface $form_state) {
$triggering_element = $form_state
->getTriggeringElement();
if (!empty($triggering_element['#autosave_form_state_timestamp'])) {
// Set the timestamp of the autosaved state which has to be used to
// restore the form on rebuild.
$form_state
->set('autosave_form_state_timestamp', $triggering_element['#autosave_form_state_timestamp']);
$form_state
->setRebuild();
}
}