Have you considered adding this to the elements class? I had not seen this
technique before reading this so I did a quick search and found
http://www.stuffandnonsense.co.uk/archives/trimming_form_fields.html. It
gives an example of using css and js to toggle between displaying optional
fields. Some forms have very few required fields and a great number of
optional fields, and being able to hide the optional fields would greatly
enhance the user experience, especially for mobile users.

I'm very much in favor of what you've done with the label. It simplifies my
effort, adds consistency, is more visually impressive and enhances the users
experience. Now I'm able to highlight the labels of required fields in green
throughout my project by adding just one line to my form.css file:

label.required { color: green; }

Thanks,

Jim



Matthew Weier O'Phinney-3 wrote:
> 
> -- Roberto Bouza <[EMAIL PROTECTED]> wrote
> (on Tuesday, 04 March 2008, 10:41 PM -0500):
>> I'm doing this piece of code in Zend_Form:
>> 
>> $form->addElement('text', 'first_name');
>>         $form->first_name->setLabel('first_name')
>>                           ->setDecorators(array(
>>                                               array('ViewHelper', array
>> ('helper' => 'formText')),
>>                                              array('Label', array('class'
>> =>
>> 'text_box_label')),
>>                                              array('HtmlTag', array('tag'
>> =>
>> 'div', 'class' => 'text_box'))
>>                                          ));
>> 
>> And when the form gets rendered the source looks like this:
>> 
>> 
>> <div class="text_box"><label for="first_name" class="text_box_label
>> optional">Nombre</label>
>> 
>> 
>> <input type="text" name="first_name" id="first_name" value=""></div>
>> 
>> Just on the label - class="pepe  - a optional is appearing there. Any
>> ideas?
> 
> That's by design; you'll also notice that required elements get a an
> additional 'required' class in the label. This is to allow you to use
> CSS hinting for optional and required elements.
> 
> -- 
> Matthew Weier O'Phinney
> PHP Developer            | [EMAIL PROTECTED]
> Zend - The PHP Company   | http://www.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zned_Form-%22optional%22-appearing-in-class-tp15842588s16154p15852489.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to