views:

117

answers:

2

I have some Zend_Form

$text = new Zend_Form_Element_Textarea('text');
$text->setLabel('Leave a reply')
     ->setAttrib('rows', 9)
     ->setAttrib('cols', 50)
     ->addValidator('NotEmpty')
     ->setRequired(true)
     ->setAttrib('class', 'comment_form');

I wand to style this form, to add some style for label tag and another style for textarea tag. How can I do that?

+2  A: 

You need to modify the decorators directly:

$text->getDecorator('Label')->setOption('class', 'my-class-name');

Or you can style the element appropriately using the generated ID as suggested by Mark. As a general rule if it needs to apply to more than a single form id do it the way i suggest to minimize the css length and add some clarity.

prodigitalson
Didn't know you could do it this way. I would suggest this way instead of mine
Mark
A: 
  $textarea = new Zend_Form_Element_Textarea ('intro', array(
  'label' => 'Introduction',
  'attribs' => array ('style' => 'width: 100px'),
  ));

or if you have already got an element in $textarea

$textarea->setAttrib('style', 'width: 100px;');
Sergey Toropenko