2009-04-21 85 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元素!!!!!