我使用我的类来改变我的窗体的装饰。换句话说,而不是调用
Application_Form_Login extends Zend_Form我使用:
Application_Form_Login extends My_Form在我的"My_Form“类中,我定义了以下内容:
protected $_disableLoadDefaultDecorators = true;
protected $_elementDecorators = array(
'ViewHelper',
array(
'Errors',
array(
'data-icon'=>"alert",
'class'=>"ui-body ui-body-e errors"
)
),
'Label',
array(
array(
'row' => "HtmlTag"
), array(
'tag'=>"div",
'data-role'=>"fieldcontain"
)
)
);这在我的常规表单上效果很好。但是一旦我使用了jQuery表单:
$this->addElement(new ZendX_JQuery_Form_Element_AutoComplete(
"ac1",
array('label' => "Your Address:"))
));这对它们没有任何影响,它们仍然使用默认的装饰器进行渲染。你知道如何为jQuery表单元素全局设置装饰器吗?
发布于 2012-02-05 21:00:00
我已经解决了这个问题。以这种方式定义的任何默认装饰器也可以在任何ZendX_JQuery_Form_Element上工作
如果
addElement函数内部创建的。换句话说,不是以这种方式创建元素:$this->addElement(new ZendX_JQuery_Form_Element_AutoComplete( "address",array( 'label‘=> "Your Address:“);
您应该这样创建它:
$this->addElement('AutoComplete','address',array( 'label‘=> "Your Address:“));
因为当addElement自己创建元素时,它会将默认修饰符传递给创建函数。否则,这些元素将在表单context.
Zend_Form中没有AutoComplete元素。因此,用来构建表单的类(包括所有全局设置和装饰(在我的例子中是:"My_Form")应该扩展ZendX_JQuery_Form,而不是Zend_Form
ZendX_JQuery_Form_Element_UiWidget需要UiWidgetElement装饰器)。所以我们用ZendX的:UiWidgetElement.
替换ViewHelper装饰器
https://stackoverflow.com/questions/9113654
复制相似问题