Zend_Form - 添加 CSS 类 :: 如何在 Zend_Form 中添加 css 类到标签?

发布于 2024-09-08 04:12:20 字数 388 浏览 1 评论 0原文

如何在 Zend_Form 中添加 css 类到标签?

这是html方式

<dt><label for="foo" class="label-design">Foo</label></dt>

我如何用Zend_Form写上面的行

(我知道如何编写标签,但我不知道如何添加 ccss 类。

$model = new Zend_Form_Element_Text('model');
$model->setLabel('Model');

谢谢,

How can I add css class to label in Zend_Form?

This is html way:

<dt><label for="foo" class="label-design">Foo</label></dt>

How can I write above row with Zend_Form?

(I know how to write label but i dont know how can i add ccss class.

$model = new Zend_Form_Element_Text('model');
$model->setLabel('Model');

)

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纵性 2024-09-15 04:12:20

最简单的方法是将类添加到 dt 元素,而不是标签:

$model->addDecorator(
    new Zend_Form_Decorator_Label(array('tag' => 'dt', 'class' => 'label-design'))
);

然后只需将 CSS 选择器从 label.label-design 修改为 dt.label-design label

The easiest way is to add class to dt element, not to label:

$model->addDecorator(
    new Zend_Form_Decorator_Label(array('tag' => 'dt', 'class' => 'label-design'))
);

And then just modify your CSS selector from label.label-design to dt.label-design label

王权女流氓 2024-09-15 04:12:20

可以将类直接添加到标签中。这是 Matthew Weier O'Phinney 撰写的一篇精彩文章,描述了有关装饰器的所有内容: http:// devzone.zend.com/1240/decorators-with-zend_form/

为了回答你的问题,我会这样做:

$model->setLabel("Model")
      ->setDecorators(array(array("Label",array("class"=>"full")),"ViewHelper"));

It is possible to add a class directly to the label. Here is an awesome article from Matthew Weier O'Phinney describing all about decorators: http://devzone.zend.com/1240/decorators-with-zend_form/.

To answer your question, I would do it like this:

$model->setLabel("Model")
      ->setDecorators(array(array("Label",array("class"=>"full")),"ViewHelper"));
违心° 2024-09-15 04:12:20

直接将“label-design”类添加到元素 $model 的标签中:

$model->addDecorator('Label', ['class' => 'label-design']);

Directly add the class 'label-design' to the label of your element $model:

$model->addDecorator('Label', ['class' => 'label-design']);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文