Show content validation errors when Saving Ajaxy - #3793
Merged
bobvandevijver merged 4 commits intoAug 13, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the “ajaxy save” path so that content-validation failures are returned as JSON (rather than HTML) and can be displayed in the editor UI without a full page reload, matching the classic (non-ajax) UX for validation feedback.
Changes:
- Add a dedicated JSON (HTTP 422) response for content-validation violations on XHR saves.
- Update the ajaxy-save JS handler to safely render validator messages (text-only) and show inline alert blocks above the edit form.
- Add a PHPUnit test covering the controller’s ajaxy validation-error JSON contract.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/php/Controller/Backend/ContentEditControllerSaveTest.php | Adds a controller unit test for ajaxy validation-error JSON responses. |
| src/Controller/Backend/ContentEditController.php | Returns validator violations as JSON (422) for XHR saves via a new helper. |
| assets/js/app/ajax-save.js | Displays validation errors inline and sanitizes toast body by using .text(). |
Suppressed comments (2)
tests/php/Controller/Backend/ContentEditControllerSaveTest.php:100
- Setting the protected
$configproperty viaReflectionProperty::setValue()requiressetAccessible(true)(as done in other tests liketests/php/Twig/TokenParserTestCase.php). Without it, this assignment can fail and leave$this->configuninitialized, breaking the test.
(new ReflectionProperty(TwigAwareController::class, 'config'))->setValue($controller, $this->configWithValidatorEnabled());
assets/js/app/ajax-save.js:139
- Code style in this file consistently uses a space between
functionand the parameter list (e.g.function (toastEl)above). The new callback usesfunction(error), which is inconsistent and may trip linting.
let messages = response.errors.map(function (error) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bobvandevijver
deleted the
mindaugasjackunaspc-fix/validation-errors-on-ajaxy-save
branch
August 13, 2026 19:41
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.
Resubmit of #3769.