-
Notifications
You must be signed in to change notification settings - Fork 87
Form implements InputFilterProviderInterface - validators fix #82
base: develop
Are you sure you want to change the base?
Form implements InputFilterProviderInterface - validators fix #82
Conversation
Does this fix mean, that I have to copy all filters from method |
@akrabat Could you have a look on it, please? |
…m getInputFilterSpecificaiton
@froschdesign @akrabat rebased |
Is this a BC break? |
i.e. if I add an email element and specify an additional validator that the length must be greater than 5, does this PR mean that the EmailAddress validator is no longer added? |
@akrabat I've created an example here: https://gist.github.com/webimpress/e08e5a8928cbc3fec249fdc723705652 So, without my fix we have got:
and with my fix we have:
Basically there is something wrong. I've decided to do this way, so override default validators. In my application always I'm using fieldset and always when I get field from fieldset (from a form) validators specified in Please note, I haven't changed any tests, so I haven't break (tested) functionality. IMHO if you implement form with |
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 is a BC break, as it's a break in expectations. As an example, the comments in #78 indicate that developers are expecting that InputProvider
elements are merged with the related input from an InputFilterProvider
fieldset. This allows them to alter the input (e.g., change the required
flag, add additional validators and filters) without needing to provide a full specification for the element.
That said, I can also see how this would be an area rife for problems, and we should likely revisit for a v3 release.
This repository has been moved to laminas/laminas-form. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
This repository has been closed and moved to laminas/laminas-form; a new issue has been opened at laminas/laminas-form#44. |
When Form implements
InputFilterProviderInterface
and validators for an element are defined in methodgetInputFilterSpecification
, only these validators should be added to theInputFilter
of the Form for the element.The same behavior should be for Fieldsets and it works fine. Basically, validators defined in
getInputFilterSpecification
should override default validators of the Element.