Daniel,
Which release are you using ?
Why do you call isUploaded() instead of isValid() ?
PS: The doc does not mention that you should do isUploaded... it mentions
isValid()
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Daniel Latter" <[email protected]>
To: "Zend Framework General" <[email protected]>
Sent: Monday, May 04, 2009 6:46 PM
Subject: [fw-general] Optional File Upload
Hi,
I have an optional File upload element on my form, the current docs state
the following to get an optional form element:
$element = new Zend_Form_Element_File('foo');
$element->setLabel('Upload an image:')
->setDestination('/var/www/upload')
->setRequired(false);
$element->addValidator('Size', false, 102400);
$form->addElement($element, 'foo');
// The foo file element is optional but when it's given go into here
if ($form->foo->isUploaded()) {
// foo file given... do something
}
When I try to sybmit the form without using the upload element I get the
fllowing error: *
The file '' could not be found*.
If I remove the validator I do not get an error, and the form processes
correctly albeit without validaiton on the element.
I also check if a file has been upload with the isUploaded() method but it
seems the a validator still gets fired even with setRequired set to false,
is this a mistake in the docs or
could this be an issue with the logic of my own code?
Thank You
Daniel Latter