ZF-10316: Form::isValid fails to populate elements when the name of the element may be filtered
Description
For example when using
$form->addElement('text','my-element');
calling $form->isValid($this->getRequest()->getPost() does not populate the element.
The problem is that the Element class internally calls filterName to set the name of the element (in this case converts 'my-element' to 'myelement'), but Form uses the name argument as passed as the key of the _elements array. In Form::isValid it iterates over the elements with foreach ($this->getElements() as $key => $element) {
and when $key doesn't correspond with posted name it fails to populate the element.
Comments
Posted by Richard Tuin (richardtuin) on 2010-11-27T07:01:46.000+0000
Patch fix and associated unit tests for this problem are attached.
Posted by Richard Tuin (richardtuin) on 2011-01-23T06:40:46.000+0000
Elaboration on my patch: There is no way to fix this while ensuring backwards compatibility. Up to other contributors to decide whether this is acceptable.
Posted by Frank Brückner (frosch) on 2012-07-30T13:12:59.000+0000
I think with some migration notes in docs we can add this to the 1.12 branch.