Answer way down below...
-- Greg Frith <[EMAIL PROTECTED]> wrote
(on Wednesday, 02 April 2008, 03:17 PM +0100):
> I fear this might not be my first post to the group in the next day or
> to in relation to Zend_Form, I just don't seem to be getting a complete
> grasp of it yet.
>
> My first problem. I am trying to implement mark-up for an element like
> this:
>
> <div class="input_password">
> <label for="">Password:</label>
> <input id="" name="" type="password" size="20" />
> <p><a href="#">Forgotten Password</a></p>
> </div>
>
> I configure my form using an XML config. I can get the form element
> wrapped in the div without any problems using the following config
> snippet (which is the element configuration for this element):
>
> <password>
> <type>password</type>
> <options>
> <label>Password:</label>
> <validators>
> <alnum>
> <validator>alnum</validator>
> <breakChainOnFailure>true</breakChainOnFailure>
> </alnum>
> <stringlength>
> <validator>StringLength</validator>
> <options>
> <min>5</min>
> <max>20</max>
> </options>
> </stringlength>
> </validators>
> <decorators>
> <viewhelper>
> <type>ViewHelper</type>
> </viewhelper>
> <label>
> <type>label</type>
> </label>
> <divWrap>
> <type>HtmlTag</type>
> <options>
> <tag>div</tag>
> <class>input_password</class>
> </options>
> </divWrap>
> </decorators>
> </options>
> </password>
>
> Now I understand that I cannot add a second HtmlTag decorator, but can
> anyone suggest any other way of achieving my element layout (adding the
> additional '<p><a href="#">Forgotten Password</a></p>' after the input
> element) without using a customer decorator class?
Actually, you *can* add additional decorators of the same class using
aliasing. Try this:
<?xml version="1.0"?>
<configdata>
<element>
<decorators>
<viewHelper>
<type>ViewHelper</type>
</viewHelper>
<label>
<type>Label</type>
</label>
<div>
<type>
<div>HtmlTag</div>
</type>
<options>
<tag>div</tag>
<class>input_password</class>
</options>
</div>
<p>
<type>
<p>HtmlTag</p>
</type>
<options>
<tag>p</tag>
</options>
</p>
</decorators>
</element>
</configdata>
The relevant parts are the <div> and <p> decorators -- notice that the
type in each is an array consisting of a single key/value pair -- the
key is the internal alias by which you'll refer to it, and the value is
the actual decorator type.
That said, you probably want to use the element description for setting
that particular content, and then add a 'Description' decorator to your
decorator stack.
--
Matthew Weier O'Phinney
PHP Developer | [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/