0

我正在使用两个装饰器 - 获取表格格式对齐 - 获取日期选择器(ZendX_JQuery_Form_Element_DatePicker)

两者都单独工作,但不是同时工作

错误:

Warning: Exception caught by form: Cannot render jQuery form element without at least one decorator implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface. Default decorator for this marker interface is the 'ZendX_JQuery_Form_Decorator_UiWidgetElement'. Hint: The ViewHelper decorator does not render jQuery elements correctly. 

我的获取表单功能:

$form = new Form_Job();
$form->setDecorators(Decorator::$formDecorators);
$form->setElementDecorators(Decorator::$elementDecorators);
$form->getElement('submit')->setDecorators(Decorator::$buttonDecorators);

表单类 Form_Job()

class Form_Job extends ZendX_JQuery_Form {
   public function init() {
        $element = new ZendX_JQuery_Form_Element_DatePicker('date_from');
        $element->setLabel('Campaign Period From :');
        $element->setRequired(true);
        $element->setAttrib('size', '10');
        $element->setJQueryParam('dateFormat', 'yy-mm-dd');

        $this->addElement($element);
   }
}

我从http://framework.zend.com/manual/en/zend.form.decorators.html得到了帮助

jQuery 装饰器:当心 UiWidgetElements 的标记接口

默认情况下,所有 jQuery 表单元素都使用 ZendX_JQuery_Form_Decorator_UiWidgetElement 装饰器来渲染带有特定视图助手的 jQuery 元素。这个装饰器与用于 Zend_Form 中大多数默认表单元素的 ViewHelper 装饰器有本质的不同。为了确保 jQuery 表单元素的渲染工作正常,至少一个装饰器必须实现 ZendX_JQuery_Form_Decorator_UiWidgetElementMarker 接口,这是默认装饰器所做的。如果未找到标记接口,则会引发异常。如果您想为 jQuery 表单元素特定的渲染实现自己的装饰器,请使用标记接口。

但我需要代码来实现这个,请建议

4

1 回答 1

1

得到我的答案:-

我用了

public static $formJQueryElements = array(
        array('UiWidgetElement', array('tag' => '')), // it necessary to include for jquery elements
        array('Errors'),
        array('Description', array('tag' => 'span')),
        array('HtmlTag', array('tag' => 'td')),
        array('Label', array('tag' => 'td', 'class' =>'element')),
        array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
);
$form->getElement('jq_date')->setDecorators(Decorator::$formJQueryElements);

这适用于表格对齐,适用于 jquery 元素!!!!!!

于 2009-04-23T03:57:17.687 回答