Hi Found another (better) way to customize the error messages $validator = new Zend_Validate_File_Upload(); $validator->setMessages(array('fileUploadErrorNoFile' => 'Upload an image!''));
$image = new Zend_Form_Element_File('image'); $filesmall->setLabel('Image:') ->setDestination('./temp') ->addValidator('Size', true, '1MB') ->addValidator('Extension', true, 'jpg') ->addValidator('Count', true, 1) ->addValidator($validator) <----------- ->setRequired(true); cheers holo 2009/11/19 holografix . <hologra...@gmail.com> > Hi > > Thanks. It's a good idea. Did that in the view side but still waiting for a > better solution. Maybe a custom validator, > > Cheers > holo > > 2009/11/19 Daniel Latter <dan.lat...@gmail.com> > >> Hi, >> >> What I was thinking is you could grab all the form error messages, and >> then overrwrite the message we are after using the error message key, then >> use setErrorMessages on the form, but it's a bit of a hack, and not tried? >> >> On 19 Nov 2009, at 17:20, "holografix ." <hologra...@gmail.com> wrote: >> >> Hi >> I also tried ->addValidator('Upload', false, >> array('messages'=>array('fileUploadErrorFileNotFound'=>'TEST'))) with no >> success.. >> >> Cheers >> holo >> >> >> 2009/11/19 Daniel Latter <dan.lat...@gmail.com> >> >>> Hi, >>> >>> Also, why does this: >>> >>> ->addValidator('Upload', false, >>> array('messages'=>array('fileUploadErrorNoFile'=>'TEST'))) >>> >>> give you a "*The file 'Water lilies.jpg' was not found*" error? (yes its >>> from xp's sample pictures folder) >>> >>> >>> >>> >>> >>> >>> 2009/11/19 Daniel Latter <dan.lat...@gmail.com> >>> >>>> Doh! >>>> >>>> Well I dont understand that because if it only "..checks if an upload >>>> has resulted in an error",- and in our case a file has been uploaded, so >>>> there should'nt be an error, why are we still seeing the message? must be >>>> bug? >>>> >>>> Thanks >>>> Dan >>>> >>>> >>>> >>>> >>>> 2009/11/19 holografix . <hologra...@gmail.com> >>>> >>>> Hi >>>>> >>>>> Talked too soon :) >>>>> >>>>> It shows the message in both cases: upload a file, don't upload a file. >>>>> >>>>> I keep looking for a solution and cc'd the message to Thomas Weider >>>>> toosee if I can get a solution. >>>>> >>>>> cheers >>>>> holo >>>>> >>>>> >>>>> 2009/11/19 Daniel Latter <dan.lat...@gmail.com> >>>>> >>>>> Hi >>>>>> >>>>>> Ah, ok, didn't see that, glad it's working. >>>>>> >>>>>> Thanks >>>>>> >>>>>> On 19 Nov 2009, at 00:35, "holografix ." <hologra...@gmail.com> >>>>>> wrote: >>>>>> >>>>>> Hi >>>>>> Thanks again. It works now. >>>>>> It works doing ->addValidator('Upload', true, ...) or >>>>>> ->addValidator('File_Upload', true, ...) although the manual states: >>>>>> >>>>>> 21.2. Validators for Zend_File_Transfer >>>>>> ... >>>>>> .... >>>>>> Upload: This validator is internal. It checks if an upload has >>>>>> resulted in an error. You must not set it, as it's automatically set by >>>>>> Zend_File_Transfer itself. So you do not use this validator directly. You >>>>>> should only know that it exists. >>>>>> >>>>>> Cheers, >>>>>> holo >>>>>> >>>>>> >>>>>> >>>>>> 2009/11/18 Daniel Latter < <dan.lat...@gmail.com>dan.lat...@gmail.com >>>>>> > >>>>>> >>>>>>> sorry forgot to cc list. >>>>>>> >>>>>>> >>>>>>> ---------- Forwarded message ---------- >>>>>>> From: Daniel Latter < <dan.lat...@gmail.com>dan.lat...@gmail.com> >>>>>>> Date: 2009/11/18 >>>>>>> Subject: Re: [fw-general] Zend_Form_Element_File validator >>>>>>> To: "holografix ." < <hologra...@gmail.com>hologra...@gmail.com> >>>>>>> >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> You do this: >>>>>>> >>>>>>> $image = new Zend_Form_Element_File('logo'); >>>>>>> $image->setLabel('Image:') >>>>>>> ->setDestination($this->getimageUploadDir()) >>>>>>> >>>>>>> ->addValidator('Size', true, '1MB') >>>>>>> ->addValidator('Extension', true, 'zip') >>>>>>> ->addValidator('Count', true, 1) >>>>>>> ->addValidator('File_Upload', true, >>>>>>> array('messages'=>'YOUR MESSAGE HERE')) >>>>>>> ->setRequired(true); >>>>>>> $this->addElement($image); >>>>>>> >>>>>>> It took me ages to figure this out, as the validaor doesnt conform to >>>>>>> the normal naming conventions of the other validators. I dont know if >>>>>>> this >>>>>>> is >>>>>>> an issue or not? I had to dig into the source code to find it. >>>>>>> >>>>>>> Thanks >>>>>>> Dan >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> 2009/11/18 holografix . < <hologra...@gmail.com>hologra...@gmail.com >>>>>>> > >>>>>>> >>>>>>>> Hi >>>>>>>> Thank you but I don“t see how to set the custom error messages for >>>>>>>> the Zend_Form_Element_File. I've read the manual before posting this >>>>>>>> question but didn't found anything. I'm having this problem only with >>>>>>>> file >>>>>>>> elements. >>>>>>>> >>>>>>>> Cheers >>>>>>>> holo >>>>>>>> >>>>>>>> 2009/11/18 Daniel Latter < <dan.lat...@gmail.com> >>>>>>>> dan.lat...@gmail.com> >>>>>>>> >>>>>>>> On the element itself because that error message is being triggered >>>>>>>>> by the 'required' flag. >>>>>>>>> >>>>>>>>> The manual is pretty clear on this section. >>>>>>>>> >>>>>>>>> Thanks >>>>>>>>> >>>>>>>>> 2009/11/18 holografix . < <hologra...@gmail.com> >>>>>>>>> hologra...@gmail.com> >>>>>>>>> >>>>>>>>> Hi >>>>>>>>>> I have a form with a required file element. If file is empty, I >>>>>>>>>> get "fileUploadErrorNoFile" => "The file 'image' was not uploaded" in >>>>>>>>>> $form->getMessages(). >>>>>>>>>> >>>>>>>>>> Which validator should I add to the element to customize this >>>>>>>>>> error message ? >>>>>>>>>> >>>>>>>>>> $image = new Zend_Form_Element_File('image'); >>>>>>>>>> $filesmall->setLabel('Image:') >>>>>>>>>> ->setDestination('./temp') >>>>>>>>>> ->addValidator('Size', true, '1MB') >>>>>>>>>> ->addValidator('Extension', true, 'zip') >>>>>>>>>> ->addValidator('Count', true, 1) >>>>>>>>>> ->setRequired(true); >>>>>>>>>> >>>>>>>>>> Thanks in advance. >>>>>>>>>> Cheers >>>>>>>>>> holo >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> >