Thanks. But I don't see how can it be applied to a full form. For example, a form created like this:
$form = new Zend_Form(); $form->setAction('/usr/login') ->setMethod('post') ->setDecorators(array(array('ViewScript', array('class' => 'form element', 'viewScript' => 'index/form-test.phtml')))); // Create and configure username element: $username = $form->createElement('text', 'username'); <snip> Here, the viewScript is decorator is set to form-test.phtml, but I can't decorate the whole form using the view script? I will have hundreds of files if I have to create a view file for each element that needs more control (and allows designers to edit). Matthew Weier O'Phinney-3 wrote: > > -- asadkn <[EMAIL PROTECTED]> wrote > (on Friday, 11 April 2008, 02:25 PM -0700): >> I want to keep the forms separated in the views and thus would like to >> parse >> generated forms in views. Instead of relying on Zend_Form decorators >> generated HTML, I would like to do it all manually. It gets extremely >> messy >> when I have to use decorators with few of my HTML-rich forms. > > Please check out the ViewScript decorator in the documentation; this is > probably the best fit for your needs. Set your form to use this > decorator, and then you can customize the output of your form as you see > fit. You can find that documentation on the following manual page: > > > http://framework.zend.com/manual/en/zend.form.standardDecorators.html#zend.form.standardDecorators.viewScript > >> Perhaps I want to create <div> and other such HTML elements myself, but >> use >> Zend_Form's decorators to create the input, select, etc. (and obviously >> have >> them filled when editing). That still should save me from writing lot of >> repeated code. >> >> In views, I wish if something like this was possible: (where $this->form >> is >> a form created using Zend_Form in the controller) >> >> <div> - <?php echo $this->form->getElement('username')->render(); >> ?></div> > > In your view script (used with the ViewScript decorator, as recomended > above), you could do exactly that, only easier: > > <div><?php echo $this->form->username ?></div> > >> As I see it, each element's data is protected and thus cannot be accessed >> from outside. Maybe I should try sub-classing Zend_Form each time but >> that >> still will require me to spend a lot of time to figure out how to do it >> right. > > Not true -- there are accessors for every member stored in the form > elements, and most metadata is actually directly accessible as virtual > members using overloading. Please read up on the documentation: > > > http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.metadata > > > -- > Matthew Weier O'Phinney > Software Architect | [EMAIL PROTECTED] > Zend - The PHP Company | http://www.zend.com/ > > -- View this message in context: http://www.nabble.com/Is-anyone-processing-Zend_Form-forms-manually-in-the-views--tp16629046p16710256.html Sent from the Zend Framework mailing list archive at Nabble.com.