ZF-7404: Zend_Form_Element_Hash does not set a value when renderViewHelper() is called

Issue Type: Bug Created: 2009-07-28T10:39:40.000+0000 Last Updated: 2009-12-07T00:08:22.000+0000 Status: Resolved Fix version(s): - 1.9.6 (24/Nov/09)

Reporter: Tom Van Herreweghe (miljar) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: - ZF-8419

Attachments: - Element.diff


When you have a Zend_Form_Element_Hash element in your form, and you try to render the element not via the regular render() method, but via renderViewHelper(), then the element is rendered without the token set in the value.

The regular render() method is normally inherrited from Zend_Form_Element, but it is redefined so that the method initCsrfToken() is called to initialize the token in the session, before the rendering takes place.

Perhaps the renderViewHelper() method should be explicitly defined in Zend_Form_Element_Hash, so initCsrfToken() can also be invoked before rendering the ViewHelper.


Posted by Jelle-Jan van Veelen (pelle) on 2009-11-19T03:12:37.000+0000

I encountered this one for the second time. Would it be possible to have some kind of initialisation / preparation method that is called before the element is rendered?

As Tom points out, the initCsrfToken() method is only called from within the render() method.

Posted by Mon Zafra (monzee) on 2009-11-19T20:09:58.000+0000

Here is my proposed fix. I made the magic render method call the element's render() method, but the parent::render() call is skipped by checking a flag which is set before and after the render() call inside the magic method. Please review.

Posted by Mon Zafra (monzee) on 2009-11-19T20:54:33.000+0000

Sorry, was only checking out the resolve page, accidentally submitted ;)

Posted by Mon Zafra (monzee) on 2009-11-19T22:18:32.000+0000

Changed diffs to svn-generated diffs instead of Netbeans.

Posted by Matthew Weier O'Phinney (matthew) on 2009-11-20T11:28:10.000+0000

Patches applied to trunk and 1.9 release branch -- thanks!

Posted by Jason Hutchens (jasonhutchens) on 2009-11-29T19:12:03.000+0000

The introduction of _isPartialRendering causes Zend_Form_Element_File::render() to be called from Zend_Form_Element_File::renderViewHelper(), which raises an exception when the form element has no decorators. This breaks the file upload form on our site. I've logged this as ZF-8419.

A better solution would be to implement Zend_Form_Element::partialRender(), with an empty default implementation, and for Zend_Form_Element_Hash to implement this to fix ZF-7404.

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.