Your header is misleading as you are not adding decorators. You are delete
the default decorators and set your own.
So you erased the file decorator which means that your file elements are no
longer named correct according to the standard.
Add the file decorator when using files, otherwise the file element will not
work except you add a own implementation of a file decorator.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Jeremy Dunn" <jeremy@jsdunn.info>
To: <fw-mvc@lists.zend.com>
Sent: Monday, November 17, 2008 8:43 PM
Subject: [fw-mvc] Zend_Form exception when adding decorators to
Zend_Form_Element_File
> Hello,
>
> I'm using the code below to create file upload boxes, but I am receiving
> the following error only when I add the element decorators. The error
> occurs also if I use $uploadBox->setMultiFile() instead of the for
> loop. The decorators I'm using work for my other <input> fields.
>
> Thanks in advance for any suggestions!
> Jeremy
>
>
> Error:
> ------
> *Warning*: Exception caught by form: "file1" not found by file transfer
> adapter Stack Trace:
> #0 C:\Program
> Files\wamp\php_include\Zend\File\Transfer\Adapter\Abstract.php(877):
> Zend_File_Transfer_Adapter_Abstract->_getFiles('file1')
> #1 C:\Program Files\wamp\php_include\Zend\Form\Element\File.php(632):
> Zend_File_Transfer_Adapter_Abstract->getFileInfo('file1')
> #2 C:\Program
> Files\wamp\php_include\Zend\Form\Decorator\ViewHelper.php(205):
> Zend_Form_Element_File->getValue()
> #3 C:\Program
> Files\wamp\php_include\Zend\Form\Decorator\ViewHelper.php(235):
> Zend_Form_Decorator_ViewHelper->getValue(Object(Zend_Form_Element_File))
> #4 C:\Program Files\wamp\php_include\Zend\Form\Element.php(1911):
> Zend_Form_Decorator_ViewHelper->render('')
> #5 C:\Program
> Files\wamp\php_include\Zend\Form\Decorator\FormElements.php(100):
> Zend_Form_Element->render()
> #6 C:\Program Files\wamp\php_include\Zend\Form\DisplayGroup.php(875):
> Zend_Form_Decorator_FormElements->render('')
> #7 C:\Program
> Files\wamp\php_include\Zend\Form\Decorator\FormElements.php(100):
> in *C:\Program Files\wamp\php_include\Zend\Form.php* on line *2616*
>
>
> Code:
> -------
>
> class My_Form_UploadTest extends Zend_Form
> {
> ...
>
> $displayGroupElements = array();
>
> //file upload boxes
> for($i = 1; $i <= $this->_numFileBoxes; $i++) {
> $uploadBox = new Zend_Form_Element_File("file$i");
> $uploadBox->setLabel("File #$i");
> $uploadBox->setRequired(true);
> $uploadBox->addValidator('Extension', false,
> 'jpg,jpeg,tif,tiff,gif,png,tga,psd,pdf,bmp,doc,zip,gz,rar');
> $uploadBox->addValidator('FilesSize', false, 524288000); //max
> upload size is 500MB
> $uploadBox->setDecorators(array(
> array('ViewHelper', array('escape' => false)),
> array('Description', array('tag' => 'span', 'escape' => false)),
> 'Errors',
> array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class'
> => 'element')),
> array('Label', array('tag' => 'td','escape' => false)),
> array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
> ));
>
> $this->addElement($uploadBox);
> $displayGroupElements[] = $uploadBox->getName();
> }
>
> //define display group
> $this->addDisplayGroup($displayGroupElements,
> 'uploadImageDisplayGroup',
> array(
> 'legend' => 'Upload File(s)'
> )
> );
>
> ...
>
没有评论:
发表评论