1
如何在jQuery的元素使用部分裝飾ZendX jQuery的裝飾
我使用的表單元素驗證碼:
$title = new Zend_Form_Element_Text('title');
$title->setRequired(true)
->setAttrib('class', 'inputbox')
->setLabel('Title');
$title->viewScript = 'RegElement.phtml';
$title->setDecorators(
array(
array('ViewScript', array('class' => 'RegElement'))
)
);
但是當我使用jQuery的元素我不知道如何實現它:
$datePicker = new ZendX_JQuery_Form_Element_DatePicker(
"datePicker1", array("label" => "Date:")
);
$datePicker->viewScript = 'RegElement.phtml';
$datePicker->setDecorators(
array(
array('ViewScript', array('class' => 'RegElement'))
)
);
//views/scripts/RegElement.phtml
<li class="row <?php echo $this->class ?>">
<div class="cont-error">
<?php echo $this->formErrors($this->element->getMessages()); ?>
</div>
<div class="rowfields">
<?php echo $this->formLabel($this->element->getName(),
$this->element->getLabel()) ?>
<?php
echo $this->{$this->element->helper}(
$this->element->getName(),
$this->element->getValue(),
$this->element->getAttribs()
)
?>
</div>
<div class="hint"><?php echo $this->element->getDescription() ?></div>
</li>
並顯示此錯誤:
Warning: Exception caught by form: Cannot render jQuery form element without at least one decorator implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface.
我需要用相同的格式顯示datePicker。但我不知道如何實現這個接口。 感謝您的幫助。