ZF-4918: Problems in Zend_Form_Element_File while setting Decorators
Description
I am using ZF 1.7 and i found a problem in it (also found same problem in 1.6.2 but not in 1.6.1); when i try to set decorators (using setDecorators) for file element in my Form (using Zend_Form_Element_File ) it Throws following exception.
Warning: Exception caught by form: Unknown file Stack Trace: #0 C:\wamp\www\company\library\Zend\Form\Element\File.php(357): Zend_File_Transfer_Adapter_Abstract->getFilters('product_image') #1 C:\wamp\www\company\library\Zend\Form\Element.php(524): Zend_Form_Element_File->getFilters() #2 C:\wamp\www\company\library\Zend\Form\Element.php(541): Zend_Form_Element->_filterValue(NULL, NULL) #3 C:\wamp\www\company\library\Zend\Form\Decorator\ViewHelper.php(201): Zend_Form_Element->getValue() #4 C:\wamp\www\company\library\Zend\Form\Decorator\ViewHelper.php(231): Zend_Form_Decorator_ViewHelper->getValue(Object(Zend_Form_Element_File)) #5 C:\wamp\www\company\library\Zend\Form\Element.php(1905): Zend_Form_Decorator_ViewHelper->render('') #6 C:\wamp\www\company\library\Zend\Form\Decorator\FormElements.php(100): Zend_Form_Element->render() #7 C:\wamp\www\company\library\Zend\Form.php(2596): Zend_Form_Decorator_FormElements->render('') #8 C:\wamp\www\company\library\Zend\Form.php(2611): Zend_Form->render() #9 C: in C:\wamp\www\company\library\Zend\Form.php on line 2616
I face this problem only in versions 1.6.2 and 1.7, whereas it goes fine for version 1.6.1 of Zend Framework. I heard that someone has fixed it but no Luck i got on it!
Following is my Code snippet of form:
class ProductForm extends Zend_Form { $decorator = array( 'ViewHelper', array('Description',array('tag'=>'','escape'=>false)), 'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row'=>'HtmlTag'),array('tag'=>'tr')) ); public function __construct($options = null, $pCatg = 0) { parent::__construct($options); $this->setName('productcategory'); $this->setAction(""); $this->setAttrib('enctype', 'multipart/form-data');
$prodImg = new Zend_Form_Element_File('product_image');
$prodImg->setLabel('Product Image');
->setDecorators($this->decorator);
}
}
Please check it,
Thanks Ahsan Shahzad
Comments
Posted by Thomas Weidner (thomas) on 2008-11-12T04:56:05.000+0000
Is there a reason why you deleted the "FILE" decorator ?
Images don't work when you erase the image decorator, and files do not work when you delete the file decorator.
Posted by Thomas Weidner (thomas) on 2008-11-13T15:02:22.000+0000
Closed due to non-response