ZF-4342: $form->setName('nameAttr'); has no effect

Issue Type: Bug Created: 2008-09-21T03:29:59.000+0000 Last Updated: 2010-12-17T08:42:06.000+0000 Status: Resolved Fix version(s): Reporter: Didier Maurer (ploum) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: - ZF-10791



hello, i'm trying to set up a form with a name attribute, but without success:

$form = new Zend_Form(); $form ->setAttrib ('id', 'idAttr'); $form ->setAttrib ('class', 'classAttr'); $form ->setName('nameAttr'); [...]

I've seen that $name = $form->getName(); is returning the right value ('nameAttr'), but $this->view->form = $form;



form id="idAttr" enctype="application/x-www-form-urlencoded" class="classAttr" action="" method="post">

If I remove or comment: $form ->setAttrib ('id', 'idAttr');

it produces:


form id="nameAttr" enctype="application/x-www-form-urlencoded" class="classAttr" action="" method="post"> (see ZF-3643 too)

thanks for your answer. Didier Maurer


Posted by Matthew Weier O'Phinney (matthew) on 2008-11-07T14:35:52.000+0000

According to the W3C, "name" is not a valid attribute of


form>, while "id" is. If you set an explicit id on the form, it will be used; otherwise, it uses the form name as the id attribute. This is by design.

Posted by Adam Lundrigan (adamlundrigan) on 2010-12-17T08:42:06.000+0000

This discussion has emerged again in ZF-10791

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.