-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Choice loader is not validated against unknown choice(s) #23679
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
Comments
This is the drawback of lazy loading choices, we cannot validate a submitted value without loading all choices. I agree this is a kind of BC break though, we should find a way to deprecate this path, to enforce usage of proper constraints. |
Hm.. defining a constraint kinda defeats laziness as well no? Cant we use I dont think we should deprecate this behavior. |
Indeed, but without violating SRP. |
I always liked choice type validating out-of-the-box for unknown choices. It's a nice safety net. But you're right i never defined constraints for choice fields :)) i rely on the behavior of forms for this. Basically i choose between forms and the standalone validator per use-case, and mostly it's forms TBH. It's at least weird to have different behavior between "choices" and "choice_loader". |
And this is why I think a deprecation is necessary to make it clear. Relying on internal form behavior to validate data is wrong. |
Okay.. as forms already integrates constraint validation. Why not auto register a choice constraint... isnt that plain convenient? I.e. normalize constraints option and prepend it. |
IMO This is a good idea to consider when revamping type guessing. |
This PR was merged into the 3.4 branch. Discussion ---------- [Form] filter out invalid Intl values | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23679 | License | MIT | Doc PR | Commits ------- a2d6940 filter out invalid Intl values
This PR was merged into the 4.1 branch. Discussion ---------- [Form] filter out invalid language values | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23679 | License | MIT | Doc PR | Commits ------- ed97568 filter out invalid language values
While having this form wtih a language type and custom choice type, i noticed submitting an unknown value triggers a transformation value (thus form error) on the choice field but not for the language field.
This worked OK in 2.7
3.2

2.7

The text was updated successfully, but these errors were encountered: