Open
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds AJAX support for FormIt form submissions to address limitations with AjaxForm's error handling. The implementation includes a new frontend JavaScript library that intercepts form submissions, a backend PHP endpoint to process AJAX requests, and fixes a bug with the reCAPTCHA instanceof check (issue #260).
Changes:
- Added AJAX form submission support with client-side JavaScript and server-side endpoint
- Fixed reCAPTCHA service instanceof check and improved error handling
- Added lexicon entries for AJAX-related error messages across multiple languages
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| assets/components/formit/js/web/formit.js | New frontend JavaScript for AJAX form handling with event system and callbacks |
| assets/components/formit/action.php | New backend endpoint that processes AJAX submissions via MODX API mode |
| core/components/formit/src/FormIt/Request.php | Fixed reCAPTCHA instanceof bug, added AJAX token generation and JS registration |
| core/components/formit/src/FormIt/Service/RecaptchaService.php | Improved error handling by consistently returning RecaptchaResponse objects |
| core/components/formit/src/FormIt/Hook/Recaptcha.php | Added null coalescing operators for safer POST data access |
| core/components/formit/src/FormIt.php | Removed unused processForm method |
| core/components/formit/lexicon/*/default.inc.php | Added error messages for missing/expired configuration in 11 languages |
| _build/gpm.yml | Added frontend_js system setting configuration |
| .gitignore | Added build-related directories to ignore list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does it do?
Add JS script and backend handler to enable AJAX-based form submission and processing. Documentation: https://github.com/ilyautkin/Docs-1/blob/fix-formit-docs/en/extras/formit/formit.ajax.md
Why is it needed?
AjaxForm can not handle correctly FormIt errors, so we need to add Ajax supporting in FormIt
Related issue(s)/PR(s)
Fixing #260