-- Dalibor Karlović <[email protected]> wrote
(on Monday, 13 July 2009, 07:14 PM +0200):
> On Monday 13 July 2009 16:58:03 Matthew Weier O'Phinney wrote:
> > -- Dalibor Karlović <[email protected]> wrote
> >
> > (on Monday, 13 July 2009, 11:56 AM +0200):
> > > I have two selects: fieldName and sortOrder, I'd like to render them like
> > >
> > > <div class="field">
> > >   <label for="fieldName">Sort by</label>
> > >   <select id="fieldName" name="fieldName">(...)</select>
> > >   <select id="sortOrder" name="sortOrder">
> > >           <option>ASC</option>
> > >           <option>DESC</option>
> > >   </select>
> > > </div>
> > >
> > > and without using the view script for the form (this part is really
> > > important, if it wasn't, this wouldn't warrant a question here :) )
> > >
> > > So, the question is: how would you go about it?
> >
> > I'd use a DisplayGroup, and assign minimal decorators to each of the
> > elements:
> >
> >     $form->addElement('select', 'fieldName', array(
> >         // ...
> >         'decorators' => array('ViewHelper', 'Label'),
> >     ));
> >     $form->addElement('select', 'sortOrder', array(
> >         // ...
> >         'decorators' => array('ViewHelper'),
> >     ));
> >
> >     $form->addDisplayGroup(array('fieldName', 'sortOrder'), 'field', array(
> >         'decorators' => array(
> >             'FormElements',
> >             array('HtmlTag', array('tag' => 'div', 'class' => 'field')),
> >         ),
> >     ));
> 
> DOH! I forgot about DisplayGroup, in my mind it was == fieldset. :) Thanks, 
> Matthew.

By default, it *does* render within fieldsets. But that's one of the
features of Zend_Form -- you can always override the defaults. :)

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to