Skip to content

Fix EntityFilter cascading domain validation via grid criteria root form - #499

Open
adpeyre wants to merge 1 commit into
Sylius:1.16from
adpeyre:adpeyre-patch-1
Open

Fix EntityFilter cascading domain validation via grid criteria root form#499
adpeyre wants to merge 1 commit into
Sylius:1.16from
adpeyre:adpeyre-patch-1

Conversation

@adpeyre

@adpeyre adpeyre commented Jul 22, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant