-- Greg Frith <[EMAIL PROTECTED]> wrote
(on Wednesday, 02 April 2008, 08:45 PM +0100):
> Thanks for the reply Matthew, this has indeed sorted my problem.  Sorry I 
> should have noted the 'description' decorator previously.

Naw -- that's a non-obvious solution. I've pointed it out a few times,
which tells me I should probably add more documentation on that. :-)
Glad I could help, though!

> My form is now working perfectly.  I haven't seen many examples of an  
> XML configuration for a form lying around.  So for the benefit of the  
> group, I include my working configuration for my user login form below.  
> I'm certainly no Zend or Zend_Form expert, so I hope there are no major 
> errors that might miss lead.  Please all feel free to correct me!

Hey, if it works, it's not misleading at all. Thanks for sending this.
The usage of the CDATA is a good reference for others, in particular.

BTW, noticed this at the end:

> :wq

So, you're a vim addict, too? ;-)


> <userLogin>
>       <name>logIn</name>
>       <action>/login</action>
>       <method>post</method>
>       <elements>
>               <email>
>                       <type>text</type>
>                       <options>
>                               <label>Email:</label>
>                               <validators>
>                                       <email>
>                                               
> <validator>EmailAddress</validator>
>                                       </email>
>                               </validators>
>                               <filters>
>                                       <tolower>StringToLower</tolower>
>                               </filters>
>                               <decorators>
>                                       <viewhelper>
>                                               <type>ViewHelper</type>
>                                       </viewhelper>
>                                       <label>
>                                               <type>label</type>
>                                       </label>
>                                       <HtmlTag>
>                                               <type>HtmlTag</type>
>                                               <options>
>                                                       <tag>div</tag>
>                                                       
> <class>input_text</class>
>                                               </options>
>                                       </HtmlTag>
>                               </decorators>
>                       </options>
>               </email>
>               <password>
>                       <type>password</type>
>                       <options>
>                               <label>Password:</label>
>                               <description><![CDATA[<a href="#">Forgotten 
> Password</a>]]></ 
> description>
>                               <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>
>                                       <desc>
>                                               <type>Description</type>
>                                               <options>
>                                                       <tag>p</tag>
>                                                       <escape>0</escape>
>                                               </options>
>                                       </desc>
>                                       <divWrapper>
>                                               <type>HtmlTag</type>
>                                               <options>
>                                                       <tag>div</tag>
>                                                       
> <class>input_password</class>
>                                               </options>
>                                       </divWrapper>
>                               </decorators>
>                       </options>
>               </password>
>               <rememberme>
>                       <type>checkbox</type>
>                       <options>
>                               <label>Remember my login from this 
> computer</label>
>                               <vlaue>0</vlaue>
>                               <decorators>
>                                       <viewhelper>
>                                               <type>ViewHelper</type>
>                                       </viewhelper>
>                                       <label>
>                                               <type>label</type>
>                                       </label>
>                                       <divWrapper>
>                                               <type>HtmlTag</type>
>                                               <options>
>                                                       <tag>div</tag>
>                                                       
> <class>input_checkbox</class>
>                                               </options>
>                                       </divWrapper>
>                               </decorators>
>                       </options>
>               </rememberme>
>               <submit>
>                       <type>submit</type>
>                       <options>
>                               <decorators>
>                                       <viewhelper>
>                                               <type>ViewHelper</type>
>                                       </viewhelper>
>                                       <divWrapper>
>                                               <type>HtmlTag</type>
>                                               <options>
>                                                       <tag>div</tag>
>                                                       
> <class>input_submit</class>
>                                               </options>
>                                       </divWrapper>
>                               </decorators>
>                       </options>
>               </submit>
>       </elements>
> </userLogin>
>
> :wq
> Greg
>
> On 2 Apr 2008, at 16:21, Matthew Weier O'Phinney wrote:
>
>> 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/
>

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to