Btw:
What is $decorators ?

Why are you erasing the file decorator ?
Is there any reason for this ?

See the FAQ for details: Point 3 http://framework.zend.com/wiki/display/ZFFAQ/Forms

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message ----- From: "Michel Morelli" <[email protected]>
To: <[email protected]>
Sent: Monday, January 19, 2009 7:16 PM
Subject: [fw-general] Zend_Form and File upload


Hi all. I have this file upload element and it is a NOT required element
(setRequired(false)):

$mainpic = $this->createElement('file','mainpic');
       $mainpic->setLabel('Immagine di riferimento:')
               ->setDestination('/tmp');
       // ensure only 1 file
       //$mainpic->addValidator('Count', false, 1);
       // limit to 100K
       $mainpic->addValidator('Size', false, 102400);
       // only JPEG, PNG, and GIFs
       $mainpic->addValidator('Extension', false, 'jpg,png,gif');
       $mainpic->setDecorators($decorators)
               ->addDecorator('HtmlTag',array('tag' => 'div', 'class'
=> 'field_mainpic'))
               ->addDecorator('Description', array('escape' => false,
'tag' => 'span', 'class' => 'description'));

My problem is that when I click the submit button my form is not valid
and the error is in the file element, and these are the error messages :

   * The file '' could not be found
   * The file '' was not found


Where is my error ? The problem are the 'Count' and 'Extension'
validator, but why they run if the file is not required ?

M.

--
Michel 'ZioBudda' Morelli                       [email protected]
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ajaxblog.it        MSN: [email protected]
JABBER: [email protected]



Reply via email to