Hi all,
I managed to get this working by extending the ViewHelper decorator,
but I am also looking at the option that you mention Matthew. The
most confusing aspect about the decorators for me, at the moment with
the current approach is the difficulty in adding duplicates. The
issue I'm having at the present could be resolved by adding another
HtmlTag decorator, but isn't easily possible as you've mentioned. So
far, I've been very satisfied with the design of Zend_Form, but I feel
it is very important to provide more flexibility with regards to the
decorators, as this will be an area that's is likely to be used/abused
a lot by end-users.
Ultimately, seeing the ability to specify the order, and have
duplicate decorators I feel would be additions with good merit, as
well as providing the flexibility that many of us need.
Thank you very much for your hard work Matthew and crew, this is an
aspect of the Framework I've most been looking forward to in my
current applications.
Regards,
Jay M. Keith
On Jan 28, 2008 9:25 AM, Matthew Weier O'Phinney <[EMAIL PROTECTED]> wrote:
> -- 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/
>