ZF-10316: Form::isValid fails to populate elements when the name of the element may be filtered


For example when using


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.


Patch fix and associated unit tests for this problem are attached.

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.

I think with some migration notes in docs we can add this to the 1.12 branch.