public function AutosaveFormAlterTrait::autosaveFormAjax in Autosave Form 8
Ajax callback for autosaving forms.
1 call to AutosaveFormAlterTrait::autosaveFormAjax()
- AutosaveEntityFormHandler::autosaveFormAjax in src/
Form/ AutosaveEntityFormHandler.php - Ajax callback for autosaving content entity forms.
File
- src/
Form/ AutosaveFormAlterTrait.php, line 236
Class
- AutosaveFormAlterTrait
- Provides a trait for common autosave form alterations.
Namespace
Drupal\autosave_form\FormCode
public function autosaveFormAjax($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$timestamp = $form_state
->getTemporaryValue('autosave_form_last_autosave_timestamp');
if (is_numeric($timestamp)) {
$response
->addCommand(new InvokeCommand('input[name="autosave_form_last_autosave_timestamp"]', 'attr', [
'value',
$timestamp,
]));
}
return $response;
}