2009-04-21 72 views
0

工作,我用两个装饰 - 要获得表格形式排列 - 要获得日期选择器(ZendX_JQuery_Form_Element_DatePicker)Zend公司从装修不ZendX_JQuery_Form

两者都是独立工作,但不能在同一时间

错误:

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类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 Decorators: Beware the Marker Interface for UiWidgetElements

By default all the jQuery Form elements use the ZendX_JQuery_Form_Decorator_UiWidgetElement decorator for rendering the jQuery element with its specific view helper. This decorator is inheritly different from the ViewHelper decorator that is used for most of the default form elements in Zend_Form. To ensure that rendering works correctly for jQuery form elements at least one decorator has to implement the ZendX_JQuery_Form_Decorator_UiWidgetElementMarker interface, which the default decorator does. If no marker interface is found an exception is thrown. Use the marker interface if you want to implement your own decorator for the jQuery form element specific rendering.

但我需要的代码来实现这一点,请建议

回答

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元素!!!!!