问题
I have a problem with errors using Symfony2 FormComponent.
I've validation for getters in bundle:
getters:
someGetter:
- MyOwnValidator: { message: "Fail"}
After that, I want to validate form and show errors:
{{form_errors(form)}}
returns to me bunch of errors (including error for someGetter), but
{{form_errors(form.someGetter)}}
doesn't return anything.
Any ideas?
UPDATE
I've found the solution. Field, for which I implemented validation (someGetter) is a collection type without 'error_bubbling' => 'false'
option.
When I added error_bubbling, everything works fine.
回答1:
Other options to have the getters error is with http://symfony.com/doc/current/reference/forms/types/entity.html#error-mapping and http://symfony.com/doc/current/reference/forms/types/entity.html#error-bubbling
回答2:
I've found the solution. Field, for which I implemented validation (someGetter) is a collection type without 'error_bubbling' => 'false' option.
When I added error_bubbling, everything works fine.
Answer extracted from updated question.
来源:https://stackoverflow.com/questions/14719970/symfony2-validation-on-getters-show-error-on-form