Style Form Elements in Zend Framework

I have a 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, add a style for the tag tag and a different style for the textarea tag. How can i do this?

+3
source share
2 answers
  $textarea = new Zend_Form_Element_Textarea ('intro', array(
  'label' => 'Introduction',
  'attribs' => array ('style' => 'width: 100px'),
  ));

or if you already have an item in $ textarea

$textarea->setAttrib('style', 'width: 100px;');
+5
source

You need to change the decorators directly:

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

Or you can style the element appropriately using the generated identifier, as Mark suggested. Generally, if you need to apply this to more than one form identifier, do it the way I suggest minimizing the css length and adding some clarity.

+4
source

Source: https://habr.com/ru/post/1728340/


All Articles