Jquery ui Zend decorators:如何在表单上使用jquery ui类?
我使用jquery在Zend框架中创建了一个表单:Jquery ui Zend decorators:如何在表单上使用jquery ui类?,jquery-ui,zend-framework,zend-form,zendx,Jquery Ui,Zend Framework,Zend Form,Zendx,我使用jquery在Zend框架中创建了一个表单: class Contact_Form_Contact extends ZendX_JQuery_Form { public function init() { /* Form Elements & Other Definitions Here ... */ //create new element $name = $this->createElement('text',
class Contact_Form_Contact extends ZendX_JQuery_Form {
public function init() {
/* Form Elements & Other Definitions Here ... */
//create new element
$name = $this->createElement('text', 'name');
//element options
$name->setLabel("Enter your name:");
$name->setRequired(TRUE);
$name->setAttrib('size', 40);
//add element to the form
$this->addElement($name);
.....
如果请求失败,setRequired启用类=错误
如何将其重写为“ui状态错误my clean
”
Arman。认真阅读Zend的博客后,我发现使用decorator很容易做到这一点:
$this->setElementDecorators(array(
'ViewHelper',
'Label',
array('Errors', array('class'=>'ui-state-error'))
));
您可以这样设置装饰器选项,而不是覆盖装饰器:
$element->getDecorator('Errors')->setOption('class', 'ui-state-error my-clean')
这个解决方案也很有用。