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

Issue Type: Bug Created: 2010-08-14T19:38:23.000+0000 Last Updated: 2013-03-13T20:55:22.000+0000 Status: Open Fix version(s): - Next Mini Release ()

Reporter: Bernardo Signori (bernardo) Assignee: Richard Tuin (richardtuin) Tags: - Zend_Form

  • After1.12.0
  • zf-crteam-review

Related issues: Attachments: - ZF-10316-rtuin.patch


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.


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.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.