-- GirishK <[email protected]> wrote
(on Thursday, 12 March 2009, 11:41 PM -0700):
> I have to design a form in Zend. The form layout should be similar to this
>
> Login Details
> username <TEXT INPUT BOX>
> password <PASSWORD INPUT BOX>
> confirm password <PASSWORD INPUT BOX>
> country <COUNTRY COMBO BOX> state < STATE COMBO BOX>
> ciy <CITY COMBO BOX>
>
> So as you can see, first 3 elements are 'one element per row', next 2
> elements are '2 elements per row' and then again 'one element per row'.
>
> Right now i am using fieldset -> table -> tr -> td but with this all
> elements are 'one element per row'.
> How to achieve this in Zend_Form? Which decorators to use?
You can do the above fairly easily with the default decorators; check
our archives or via google for some CSS examples that render definition
list terms and definitions side by side.
Your form will need to add a label and a fieldset decorator:
$form->setLabel('Login Details')
->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'dl')),
'Fieldset',
'Form',
));
Where you have two elements per row, wrap them in a DisplayGroup with
the following decorators:
$form->addDisplayGroup(array('country', 'state'), 'countryState', array(
'decorators' => array(
'FormElements',
array('HtmlTag', array('tag' => 'div', 'class' => 'sideBySide')),
'DtDdWrapper',
)
));
Each element in that display group should then likely define decorators
for simply the ViewHelper and Label (and potentially errors), and wrap
them in a div; use CSS rules to float them side by side.
--
Matthew Weier O'Phinney
Software Architect | [email protected]
Zend Framework | http://framework.zend.com/