Fix EntityFilter cascading domain validation via grid criteria root form - #499
Open
adpeyre wants to merge 1 commit into
Open
Fix EntityFilter cascading domain validation via grid criteria root form#499adpeyre wants to merge 1 commit into
adpeyre wants to merge 1 commit into
Conversation
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.
Problem
The grid filter form validates the selected entity as if it were a real domain object, even though it shouldn't — a filter is just a search criterion, not a form meant to create or edit an entity. When the filtered entity has its own Assert constraints (e.g. NotBlank), this shows validation errors on form submission that have nothing to do with the actual filter.
Root cause
The criteria root form built in TwigGridRenderer::renderFilter() has no data_class — its data is a plain array. Symfony's FormValidator runs its automatic data-graph validation only on the root form, and for a plain array it validates each contained object against its own class constraints. entity is the only filter type whose value is such an object, so it's the only one affected.
Fix
Set 'validation_groups' => false on the criteria root form in TwigGridRenderer::renderFilter(), since it's a rendering container, not a validated business form.