-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Handle regular form elements as target elements of Zend\Form\Element\Collection
.
#6298
Conversation
Fielset, then add a CollectionInput instead of a regular input filter, respecting the target's input specification. Added Zend\InputFilter\CollectionInput and associated test case. Added tests to ZendTest/Form/Element/CollectionTest
} | ||
return $this->messages; | ||
} | ||
} |
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.
EOF EOL
I don't think you need to create a new class Have a look at #6497 and #6498 for a way of instantiating a CollectionInputFilter automatically when a collection is encountered. |
@erispre Does the suggestion by @SteveTalbot address the use case you have? If so, we should close this. If not, can you explain how the use cases differ, so we can message when to use which type? |
@erispre #6880 should fix this issue, could you pull it down and try it out? (https://github.com/adamlundrigan/zf2/tree/zf6518) |
#6880 was merged, so this just needs to be verified. |
I'll just merge the tests from this patch. |
Note that attribution will be given only as a comment to the commit, since rebasing/squashing the commits to avoid changes to unaffected code-paths is problematic. If this doesn't match expectations, then please ask for a revert and send the test code in a separate pull request.
…-collection-element' into develop Close #6298
@erispre I've manually merged the newly introduced test case into Thanks! |
The changes below allow for setting regular form elements (i.e. not a
Zend\Form\Fieldset
) as the target element of a form collection. Before this patch, this would create problems when binding a domain model. Now, a new input (Zend\InputFilter\CollectionInput
-- basically aArrayInput
with some minor changes to message handling) is set for the collection when no input filter configuration is provided. This input will take the validators and filters of the target element and loop over an array of values. This way, domain models can be hydrated from form data. (Before this, there would be no inputs nor input filters attached to theCollection
's default input filter, so all values would be lost afterForm::isValid()
was called).This pull request addresses issue #6263.