-
-
Notifications
You must be signed in to change notification settings - Fork 54
Validate template option for grid fields
#364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.13
Are you sure you want to change the base?
Conversation
| /** | ||
| * @test | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | |
| * @test | |
| */ | |
| /** @test */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use the PHP Attribute :)
| /** | ||
| * @test | ||
| */ | ||
| public function it_throws_exception_when_field_template_is_used_with_non_twig_type(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public function it_throws_exception_when_field_template_is_used_with_non_twig_type(): void | |
| public function it_throws_an_exception_when_field_template_is_used_with_non_twig_type(): void |
| ->end() | ||
| ->end() | ||
| ->validate() | ||
| ->ifTrue(fn (array $config): bool => isset($config['options']['template']) && $config['type'] !== 'twig') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an overreach that can plausibly cause conflicts with custom types.
Wouldn't it be better to reset the previous options once the type changes, we'd probably need to inject the logic somewhere inside the config merging mechanism though.
Initial error:

The error message did not clearly indicate what was wrong.
The issue was related to grid configuration merging.
In Sylius, we have:
and in some end app:
After merging, the type was set to
string, but thetemplateoption from the base configuration remained, causing the application to break.This PR introduces validation to prevent similar issues in the future, saving users from hours of debugging.