Issues

ZF-11760: setDecorators for a file element doesn;t work

Issue Type: Bug Created: 2011-09-22T10:15:50.000+0000 Last Updated: 2011-09-22T10:53:38.000+0000 Status: Closed Fix version(s): Reporter: xair (xair) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

  • zend_form_element_file

Related issues: Attachments:

Description

i am coding a zend form without using mvc. I am trying to add a file element and use the table , td and tr decorators. But this doesn't seem to work . What is the problem ? This is the code:

<pre class="highlight">
require_once 'Zend/Form.php';

class JobForm extends Zend_Form

{

       public function init()

       { 
          
          $this->setAction('index.php?apply='.$_GET['apply']) 

                         ->setMethod('post') 

                         ->setAttrib('id','myFormApply') 

                         ->setAttrib('enctype', 'multipart/form-data');

                         ;

                $coverLetter = $this->createElement('file','coverLetter')
 
                                     ->setLabel('Cover Letter*')

                                     ->setAttrib('id','coverLetter')
 
                                     ->setRequired(true)

                                     ->setDestination( './uploads') ;
                            
    
               $coverLetter->setDecorators(array(

                       'ViewHelper',

                       'Description',

                       'Errors',

                       array(array('data'=>'HtmlTag'), array('tag' => 'td')),

                       array('Label', array('tag' => 'td')),

                       array(array('row'=>'HtmlTag'),array('tag'=>'tr'))

               ));

                                
$submit = $this->createElement('button','submitApply')

->setAttrib('id','submitApply')

->setLabel('Submit'); 

                
$submit->setDecorators(array(

               'ViewHelper',

               'Description',

               'Errors', 

           array(array('data'=>'HtmlTag'), array('tag' => 
'td','colspan'=>'2','align'=>'center')),

               array(array('row'=>'HtmlTag'),array('tag'=>'tr'))

          ));

                                    
                    $this->addElement($coverLetter);
            
                    $this->addElement($submit); 
                    
    
                    $this->setDecorators(array(

                'FormElements',

                array('HtmlTag', array('tag' => 'table')),

                'Form'

                    ));

                    
        
                $this->addDecorator('Errors');

            
          
            
        }

        
}

Comments

Posted by Frank Brückner (frosch) on 2011-09-22T10:34:12.000+0000

Code tags added.

Posted by Frank Brückner (frosch) on 2011-09-22T10:35:04.000+0000

Please look at the FAQ: "Why can't Zend_Form render my File element without errors?"

http://framework.zend.com/about/faq

Posted by xair (xair) on 2011-09-22T10:53:38.000+0000

thanks that solved my issue

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts