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');
And
$username = new Zend_Form_Element_Text('username'); $username->setLabel('Username') ->setAttrib('class', 'textinput');
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?
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.