This module adds a warning message to forms when users make changes but haven't saved them. It helps prevent accidental data loss by prompting users before they navigate away from a modified form.
You can display the "You have unsaved changes" warning on a form when any input has been changed.
Just attach the defined library to your form.
/**
* Implements hook_form_alter().
*/
function YOURMODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['#attached']['library'][] = 'form_change_warning/form_change_warning';
}
Similar modules
Ask your assistant about Form change warning
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Releases
| Version | Type | Core | PHP | Release date | |
|---|---|---|---|---|---|
| 1.0.0-alpha1 | Pre-release | 10–11 | Jan 10, 2025 | ||
| 1.0.x-dev | Dev | 10–11 | Jan 10, 2025 |