-- fozzyuw <[EMAIL PROTECTED]> wrote
(on Tuesday, 09 September 2008, 07:24 AM -0700):
> I've been searching and playing around with Zend_Form for a while and I've
> gotten a much better grasp, but I'm stilling hitting a brick wall on
> something.  I'm trying to get this code structure...
> 
> - - - - - - - - - - - - - - - - - - - - 
> <form>
>     <fieldset>
>         <legend>My Form</legend>
>         <dl>
>             <dt><label>Element 1</label></dt>
>             <dd><input /></dd>
>             [...]
>         </dl>
>         * Required
>     </fieldset>
>     <input type="hidden" />
>     <input type="submit" />
> </form>
> - - - - - - - - - - - - - - - - - - - - 
> 
> I've managed to get this...
> 
> - - - - - - - - - - - - - - - - - - - - 
> <form>
>     <fieldset>
>         <legend>My Form</legend>
>         <dl>
>             <dt><label>Element 1</label></dt>
>             <dd><input /></dd>
>             [...]
>         </dl>
>     </fieldset>
> </form>
> - - - - - - - - - - - - - - - - - - - - 
> 
> What I'm missing is how to add the "hidden" and "submit" button outside of
> the "fieldset" 

Regarding hidden elements, there has been a feature request for this for
some time. The unfortunate fact, though, is that it's relatively
difficult to implement. I'm hoping to get to it for 1.7.0.

> (though, now that I think about it, should I be using a
> 'Display Group' to group the "dl" and "span" elements?  Maybe I'm
> approaching this thing all wrong and not considering doing things I
> could/should be doing?).

Yes, a display group is the way to go here; simply add all your
non-hidden, non-submit elements to the display group, and you'll be set.

> I'm also missing how to add simple HTML to a field, such as appending a "*
> Required" element after the "dl" list.

You can do that by passing some attributes to the Label decorator; in
your case, you want to set the requiredSuffix attribute:

    $element->getDecorator('label')->setOption('requiredSuffix', '* Required');

You can also pass it in at creation:

    $element->setDecorators(array(
        'ViewHelper',
        'Errors',
        array('HtmlTag', array('tag' => 'dd')),
        array('Label', array('tag' => 'dt', 'requiredSuffix' => '* Required')),
    ));

and, of course, using a configuration file, if desired.

> Any suggestions?  I'm going to play around with "Display Group".  For
> whatever reason, I wasn't thinking about using that in a SubForm.

Considering your structure, a display group is sufficient.

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to