2009/9/9 Daniel Latter <dan.lat...@gmail.com>
> Hi, > > Have a look at this: > http://www.slideshare.net/NickBelhomme/zend-framework-form-mastering-decorators > > Also regarding your code, the "HtmlTag" decorator is being applied so you > can try and set that, also you can try and clear the default > decorators. > > The *default* *decorators* on an element are: > > • ViewHelper > • Errors > • Description (only renders if a description is set) > • HtmlTag > • Label > > Try $element->*removeDecorator*('HtmlTag '); > > Thanks > Daniel > > 2009/9/9 Jayawi <jayawiper...@gmail.com> > > >> Hi there~ >> >> I'm relatively new to ZF but have enjoyed using it so far. The main issue >> I've had with ZF is with it's Form and Decorator aspects. After going >> through God knows how many articles/blogs/posts and what not, I thought I >> finally had a grasp of it. Things were working okay. >> >> I created a standard set of decorators (for Elements, Buttons and Forms) >> based on an example I saw. Recently however, I realised that I needed to >> add >> in some File Input fields into one of the forms. None of the above >> decorators worked with it. At which point, I decided to use ViewScripts on >> all the forms since it provides greater room to stylise/organise the form. >> >> The code I'm currently using, looks something like the following: >> >> site/application/forms/RegisterForm.php >> class ProjectStartContactPersonForm extends Gid_Form >> { >> public function init () >> { >> $this->setAction('') >> ->setMethod('post') >> ->setAttrib('id','formStartProject') >> ->setAttrib('enctype', >> 'multipart/form-data'); >> >> $this->addElement('text', 'textName', array('label' => >> 'Given Name')); >> $oName = $this->getElement('textName') >> ->setRequired(true) >> >> ->setDecorators(array('ViewHelper', 'Errors')); >> >> $this->addElement('file', 'filePhotograph'); >> $oPhotograph = $this->getElement('filePhotograph') >> ->setRequired(true); >> >> $this->addElement('submit', 'submitRegister', array('label' >> => 'Done')); >> $oContactPersonSubmit = >> $this->getElement('submitRegister'); >> $oContactPersonSubmit->setDecorators(array('ViewHelper', >> 'Errors')); >> >> $this->setDecorators(array(array('ViewScript', >> array('viewScript' => >> 'forms/RegisterForm.phtml')))); >> } >> } >> >> site/application/views/scripts/forms/RegisterForm.phtml >> <div id='iDivRegister'> >> <form action='' method='post'> >> <table> >> <tr> >> <td><label >> for='textName'>Name:</label></td> >> <td><?php echo $this->element->textName; >> ?></td> >> </tr> >> <tr> >> <td><label >> for='filePhotograph'>Photo:</label></td> >> <td><?php echo >> $this->element->filePhotograph; ?></td> >> </tr> >> <tr> >> <td></td> >> <td><?php echo >> $this->element->submitRegister; ?></td> >> </tr> >> </table> >> </form> >> </div> >> >> From RegisterForm.php I had to change $this->addElement('file', >> 'filePhotograph', array('label' => 'Photo')); to get it to work. prior to >> that, the File Input element was being displayed twice. >> Additionally, if ->setDecorators(array('ViewHelper', 'Errors')) was >> attached >> to the File Input object, it would throw the error "Warning: No file >> decorator found... unable to render file element in >> C:\xampp\xampp\php\PEAR\Zend\Form\Element.php on line 1929". >> I honestly can't understand what the issue is or how I'm supposed to >> resolve >> it. All the searching and reading I did lead me to more questions and no >> solution. Some of them dealt with the lack of a File Input Class in ZF >> (which I believe was a somewhat early release), while others used custom >> classes for things which didn't really clarify anything for me. >> >> Currently, the File Input Element is rendered as follows: >> <tr> >> <td><label for='filePhotograph'>Photo:</label></td> >> <td> >> <dt id="filePhotograph-label"> </dt> >> <dd><input type="file" name="filePhotograph" >> id="filePhotograph"></dd> >> </td> >> </tr> >> >> I would like to get it outside of those dt/dd tags (which suggest the >> default ZF Decorators are being applied). >> ZF Documentation I find stragely lacking in the various >> methods/variables/parameters to use. If anyone knows of a better >> reference, >> it's sure to help a great deal. >> >> I would greatly appreciate any help anyone can provde me on this. >> Thanks~ >> -- >> View this message in context: >> http://www.nabble.com/Zend_Form-File-Element---Decorator---Extremely-Confuzzled-tp25365664p25365664.html >> Sent from the Zend Framework mailing list archive at Nabble.com. >> >> >