在Zend Framework中使用默认样式设置表单元素的样式 [英] Style form elements in Zend Framework with a default style

查看:61
本文介绍了在Zend Framework中使用默认样式设置表单元素的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用自定义CSS类对表单元素进行样式设置,以对文本输入进行不同的样式设置,例如:

I'm currently styling form elements with a custom CSS class to style text inputs differently, as in:

$submit = new Zend_Form_Element_Submit('login');
$submit->setLabel('Log in')
    ->setAttrib('class', 'submit');

还有

$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username')
    ->setAttrib('class', 'textinput');

但是,假设我有多种形式,并且默认情况下要使用textinput设置所有文本元素的样式,并使用submit设置所有提交元素的样式.无论如何,全球都可以这样做吗?

But let's say I have multiple forms, and want to style all text elements with textinput and all submit elements with submit by default. Is there anyway to do this globally?

推荐答案

我不是Zend专家,但是我想您可以继承每个Zend_Form_Element_ *类并设置要在其构造函数中设置的属性-即,在Zend_Form_Element_Text_Yatta;然后将属性"class"设置为 在其构造函数中为"textinput".

I'm no Zend expert, but I guess you could subclass each Zend_Form_Element_* class and setting the attributes you want to set in their constructors - i.e subclass Zend_Form_Element_Text in Zend_Form_Element_Text_Yatta; then setting attribute 'class' to 'textinput' in its constructor.

这篇关于在Zend Framework中使用默认样式设置表单元素的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆