content_save_confirm
Description
The **Content Save Confirm** module adds a configurable confirmation dialog when saving content forms in Drupal. This module helps prevent accidental content submissions by requiring users to confirm their save action before the form is actually submitted.
Key Features
- **Configurable Form IDs**: Administrators can specify exactly which forms should display confirmation dialogs
- **Custom Confirmation Messages**: Set your own confirmation message text
- **Smart Button Detection**: Only affects save/submit buttons, not preview, delete, or cancel buttons
- **Easy Administration**: Simple configuration interface accessible from the admin menu
- **No Database Changes**: Uses Drupal's configuration system - no additional database tables required
- **Drupal 10 & 11Compatible**: Built specifically for Drupal 10 & 11 with modern JavaScript practices
Use Cases
- **Content Management**: Prevent accidental publishing of articles, pages, or other content types
- **User Registration**: Add confirmation for user registration forms
- **Important Forms**: Any form where accidental submission could cause issues
- **Editorial Workflow**: Extra safety layer for content editors and administrators
Installation
Via Composer (Recommended)
```bash
composer require drupal/content_save_confirm
```
Manual Installation
1. Download and extract the module to `modules/custom/content_save_confirm/`
2. Enable the module via Drush: `drush en content_save_confirm`
3. Or enable via admin UI: Extend → Check "Content Save Confirm" → Install
Configuration
1. Navigate to **Administration → Configuration → Content → Content Save Confirm**
2. Set your confirmation message (default: "Are you sure you want to save this content?")
3. Add form IDs (one per line) where you want confirmation dialogs to appear
Common Form IDs
- `node_article_form` - Article creation form
- `node_article_edit_form` - Article edit form
- `node_page_form` - Page creation form
- `node_page_edit_form` - Page edit form
- `user_register_form` - User registration form
- `user_form` - User profile edit form
Finding Form IDs
The module includes helpful documentation on how to find form IDs for your specific content types and forms. Common methods include:
1. **Enable logging**: The module logs all form IDs it encounters
2. **Browser developer tools**: Inspect form elements for IDs and selectors
3. **Devel module**: Use `dpm($form_id)` in hook_form_alter()
How It Works
1. The module uses `hook_form_alter()` to attach JavaScript to specified forms
2. JavaScript intercepts submit button clicks on configured forms
3. A native browser confirmation dialog appears before form submission
4. Form only submits if user confirms the action
5. Preview, delete, and cancel buttons are automatically excluded
Technical Details
- **Dependencies**: Drupal Core 10 & 11
- **JavaScript Libraries**: Uses core/jquery, core/drupal, core/once
- **Configuration Storage**: Drupal configuration system
- **No External Dependencies**: Pure Drupal core functionality
Browser Compatibility
Works with all modern browsers that support:
- JavaScript `confirm()` dialogs
- jQuery event handling
- Modern Drupal JavaScript practices
Troubleshooting
### Dialog Not Appearing?
1. Check that the correct form IDs are configured
2. Clear Drupal caches
3. Verify JavaScript console for any errors
4. Check that the module is properly enabled
### Finding the Right Form ID?
1. Enable the module's logging feature
2. Visit `/admin/reports/dblog` after accessing your forms
3. Look for "content_save_confirm" log entries showing form IDs
## Development and Support
- **Issue Queue**: Report bugs and request features on the project issue queue
- **Code Repository**: Available on Drupal.org with Git access
- **Documentation**: Comprehensive README and inline code documentation
- **Community Support**: Active maintenance and community contributions welcome
Maintainers
- Rahul Yadav - 5418ryadav
---
**Tags**: confirmation, dialog, form, save, content, prevent, accidental, safety, workflow, editorial