开发者

Style form elements in Zend Framework

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 sty开发者_StackOverflowle this form, to add some style for label tag and another style for textarea tag. How can I do that?


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.


  $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;');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜