sorry forgot to cc list. ---------- Forwarded message ---------- From: Daniel Latter <dan.lat...@gmail.com> Date: 2009/11/18 Subject: Re: [fw-general] Zend_Form_Element_File validator To: "holografix ." <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> > 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> > > 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> >> >> 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 >>> >>> >> >