Zend_File_Transfer with custom decorator required field

2 messages Options
Embed this post
Permalink
whisher

Zend_File_Transfer with custom decorator required field

Reply Threaded More More options
Print post
Permalink

Hi.

Sorry to disturb you but what's wrong in this snippet (require doesn't trigger an error if the field is empty)

// Upload Image 
        $dir = Zend_Registry::get('dir'); 
        $this->addElement('file', 'photo1', array(
            'required'   => true,
            'title' => $translator->translate('form_Ads_Tooltip_Photo'),
            'class'     => 'input-file',
            'destination' =>  $dir->uploads,
            'validators' => array(
                array('Count', false, 1),
                array('Size', false, 2097152),
                array('Extension', false, 'jpg,pjpeg'),
                array('IsImage', false,'jpeg'),
            ),
            
        ));
        $upload = $this->getElement('photo1');
        $upload->removeDecorator('Label');
        $upload->removeDecorator('HtmlTag');
        $upload->removeDecorator('DtDdWrapper');
        $upload->addDecorator('Errors');
        $upload->addDecorator('Description', array('placement' => 'prepend'));
        $upload->addFilter('Rename',$dir->uploads.'avatar_'.substr(sha1(uniqid(microtime())),0,10). '.jpg' );

after in the class

$this->setDisableLoadDefaultDecorators(true);
        $this->setDecorators(array(array('ViewScript', array('viewScript' => 'affitto/adsForm.phtml')))); 

Thanks in advance

Bye

gbhumphrey

Re: Zend_File_Transfer with custom decorator required field

Reply Threaded More More options
Print post
Permalink