-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] DateTimeType displays duplicate "invalid" error #4359
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
See also #2326 for a previous, but insufficient solution. |
Hi, i try to solve this issue, but i can't reproduce the first part with the duplicate invalid error message. Maybe i misunderstand the issue, but right now i didn't find any problem here for the duplicate error message. Can anyone explain me better, to help me to find it ? Thx |
I also just noticed this with a To reproduce it: |
Thanks for posting these infos @craue. |
To sum up, the problem is that if you enter an invalid date
If I'm not mistaken, the solution is not to mark any form invalid if any of their children is invalid as well (invalid = not synchronized in this context). Duplicate invalid messages don't really help the user, we only want to keep the most specific ones. Any objections? |
This is implemented now in the referenced PR. |
This PR was merged into the 2.1 branch. Commits ------- 4909bc3 [Form] Fixed forms not to be marked invalid if their children are already marked invalid Discussion ---------- [Form] Fixed forms not to be marked invalid if their children are already marked invalid Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: #4359 Todo: - License of the code: MIT Documentation PR: - This PR prevents unsynchronized forms from being marked invalid if any of their children is also unsynchronized (and thus also marked invalid). Displaying an invalid message twice does not help the user and, if used in conjunction with error bubbling, may lead to duplicate errors (see #4359).
@webmozart I think there is still a problem: Our user-entity has a gender property with the following validation:
If the submitted value is not "male" or "female" the error-message "This value is invalid" is displayed and not the message from the validation configuration. The second problem is the choice-validation is never executed. The reason is this if-statement: https://github.com/symfony/Form/blob/d5f40a333d6bf209230875b58e8c8da2e2caae7e/Extension/Validator/Constraints/FormValidator.php#L98 My fix for the first problem is to configure a
|
DateTimeType, when used with the widget "text", currently duplicates the invalid error when an invalid value is entered.
Also, it should be possible to configure the "invalid" messages of both the "date" and the "time" field.
The text was updated successfully, but these errors were encountered: