ZF-6867: Zend_Form_Element_File setDecorators issue

Issue Type: Bug Created: 2009-05-30T14:32:18.000+0000 Last Updated: 2009-12-15T08:23:52.000+0000 Status: Resolved Fix version(s): - 1.8.3 (09/Jun/09)

Reporter: Sergio Rinaudo (razorblade) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form

Related issues: Attachments:


Hi, I had the needs to remove all decorators for a Zend_Form_Element_File element and then add a 'div' container to it. But I get this warning:

Warning: Exception caught by form: No file decorator found... unable to render file element Stack Trace: #0 C:\wamp\myproject\library\Zend\Form\Decorator\FormElements.php(101): Zend_Form_Element_File->render() #1 C:\wamp\myproject\library\Zend\Form.php(2595): Zend_Form_Decorator_FormElements->render('') #2 C:\wamp\myproject\library\Zend\Form.php(2610): Zend_Form->render() #3 C:\wamp\myproject\application\modules\admin\views\scripts\media\edit.phtml(6): Zend_Form->__toString() #4 C:\wamp\myproject\library\Zend\View.php(107): include('C:\wamp\myproje...') #5 C:\wamp\myproject\library\Zend\View\Abstract.php(832): Zend_View->_run('C:\wamp\myproje...') #6 C:\wamp\myproject\library\Zend\Controller\Action\Helper\ViewRenderer.php(902): Zend_View_Abstract->render('media/edit.phtm...') #7 C:\wamp\myproject\library\Zend\Controller\Action\Helper\ViewRenderer.php(923): Zend_Controller_Action_Helper_ViewRenderer->renderScript('media/edit.phtm...', NULL) #8 C:\wamp\myproject\library\Zend\Controller\Action\Helper\Vi in C:\wamp\myproject\library\Zend\Form.php on line 2615

this is the code for the file element, the above warning is caused by the setDecorators method

  $mediafile = new Zend_Form_Element_File('mediafile');

Zend Framework version 1.8.1 and 1.8.2. I used the workaround explained here:…

to make it work as I need.


Posted by Thomas Weidner (thomas) on 2009-05-30T14:51:09.000+0000

Please note that this is not a bug.

Several elements like File, Image or Captcha need own decorators, otherwise they could not be rendered. As you deleted all default decorators and gave not the needed file decorator to the file element, the file element itself throws an exception as it can not be rendered properly.

This has been mentioned in FAQ. ( ) Also several issues have been filled and answered in past.

Posted by Dennis Day (dennisatddddesigns) on 2009-12-15T08:01:12.000+0000

Seems to me that the file element should check to see if the decorator is using ViewHelper and give a more descriptive error message. At least this way, people could get on the right track.

Posted by Thomas Weidner (thomas) on 2009-12-15T08:23:51.000+0000

In my opinion "File decorator not found/set" is a proper error message. You could have a file element with File and ViewHelper decorator set.

The exception was added because many people did simply not read the manual. In past there was no error at all, the file element did simply not work.

Anyway: It is mentioned within the manual at 2 places, within the FAQ, within the mailing list and also within several public places which can be found on the web.

Even when the text would be changed to "Stupid: you must add the file decorator" there are still many people which will raise an issue instead of reading or searching first. ;-)

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.