-- Jay M. Keith <[EMAIL PROTECTED]> wrote
(on Saturday, 26 January 2008, 09:55 AM -0600):
> I've been messing around with Zend_Form and I'm happy thus far.
> But, I'm having an issue with what I think should be an easy task.
> I like the current rendering in dl's.. But I'm trying to add a div or
> span immediately after the <input> tag to be a field note/description.
There are two issues here: one has to do with a limitation of how
decorators are registered, the other with ordering of decorators.
Currently, there's a limitation that you can only use one decorator of a
given type. Simon Mundy has proposed a solution that involves aliasing
that I will likely implement in the next day or two. In the meantime,
you should likely create a custom decorator.
Regarding the second issue, decorators are processed in the order in
which they are registered. Right now, that order is:
* ViewHelper (to create the input)
* Errors (creates error HTML and appends to input)
* HtmlTag (wraps content in <dd> -- which at this point includes input
element and errors)
* Label (creates label in a <dt> and prepends to content)
So, if you want to append something after the input, within the <dd>
tag, you will need to register a new decorator chain. Let's assume you
create a 'FormHint' decorator; you could then register them like this:
$element->setDecorators(array(
array('decorator' => 'ViewHelper', 'options' => array('helper' =>
'xxx'),
array('decorator' => 'FormHint'),
array('decorator' => 'Errors'),
array('decorator' => 'HtmlTag', 'options' => array('tag' => 'dd'),
array('decorator' => 'Label', 'options' => array('tag' => 'dt'),
));
(You could also do this at the form level using setElementDecorators().)
I can see an argument for being able to specify the order of decorators,
but it's so simple to register them, I'm not sure if it makes sense to
complicate the API or the implementation for the small convenience.
> Here's my desired result:
>
> <dt><label for="username">Username</label></dt>
> <dd><input type="text" name="username" id="username" value="" /><div
> class="form-note"> Minimum of 4 characters, Maximum of 32
> characters.</div></dd>
>
> I've been trying a variety of different methods including using my own
> decorators. For some reason I imagined that a simple modification
> like this would be a bit easier to do.
> Any recommendations? I started writing up another decorator to be a
> Hint/Desc/Note area, but wanted to see if there was a different
> approach.
>
> Regards,
> Jay M. Keith
>
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/