views:

1089

answers:

1

I am using two decorator - To get tabular form alignment - To get date picker (ZendX_JQuery_Form_Element_DatePicker)

both are working individually, but not at a same time

Error:

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.

My Get Form Function:

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

Form class 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);
   }
}

I got this help from 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.

But i need code to implement this, please suggest

+1  A: 

Got my answer:-

I used

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);

this works well for tabular alignment, for jquery elements !!!!!

Ish Kumar