>>>>> Now if you add a file to upload (i.e. in the above example you attach
>>>>> a
>>>>> photo to the form for upload) and the name element (i.e. the text
>>>>> element)
>>>>> *fails* validation the file is still uploaded to the "images/photos"
>>>>> folder.
>>>>>
>>>> Sounds like you might be moving the uploaded file to images/photos 
>>>> before
>>>> checking if the submitted form is valid.
>>>>
>>>
>>>Does the validator on the element break the validation chain? Maybe
>>>that is it. If it doesn't the rest would keep on processing.
>>>Generally, might be not a bad idea to upload the image and ask the
>>>user to correct the missing input. :-)
>>>
>>>Till
>>
>> The way I see it, the file should *not* be put in the destination folder
>> unless *all* of the form elements validate.
>
>This depends on how you wrote your code. Actually we can only expect what 
>you did as you only gave the form but did not outline how you did the 
>validation.
>
>Example:
>When you call getValues() before validation, then you will revceive all 
>values from the form.
>But for the file element, the file itself is the value. In this case the 
>file is transferred when only the validation of the file element is valid
as 
>you don't validate the whole form but each value independently from all 
>other elements.
>
>Greetings
>Thomas Weidner, I18N Team Leader, Zend Framework
>http://www.thomasweidner.com 

Yes. *smacks head of keyboard* getValues() is being called prior to checking
if the form is valid which is pretty standard:

if (!$form->isValid($data)) {
    return false;
}
// do something


I hope there's a big colourful banner in the reference guide that says
"calling getValues receives all files from form when and only when all
elements are valid if and only if you don't call getValues prior to checking
is the form valid".

Thanks. My apologies if I was abrupt.
-- 
View this message in context: 
http://www.nabble.com/Zend_Form_Element_File--tp23990412p24010819.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to