我創造新的widget
這樣的:警予1個CJuiDatePicker自定義部件內
class Schedule extends CWidget
{
public $address = null;
public $order = null;//order
public function init()
{
if(isset($this->order))
$this->address = $this->order->address;
}
public function run()
{
$city = City::model()->findAll(array('condition'=>'is_active = 1','order'=>'name ASC'));
$this->render('my_schedule',array('city'=>$city));
}
}
這個
widget
和view
:
<?php
$form = new CActiveForm();
$form->id = 'checkout-form';
$form->enableAjaxValidation = true;
$form->clientOptions = array(
'validateOnSubmit' => true,
'validateOnChange' => false);
$order->address = $address;
?>
<?php if(is_array($city) && count($city) > 0) : ?>
<section class="persent70">
<p>
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker',array(
'model'=>$order,
'attribute'=>'delivery',
'name'=>'delivery',
'options'=>array(
'showAnim'=>'slide',
'htmlOptions'=>array(
'class'=>'form-control',
'id' => 'delivery',
),
));
?>
<?php echo $form->error($order, 'delivery'); ?>
</p>
在這種情況下,日曆不開,但是當我使用在簡單的看法這datepicker
工作正常。
你可以嘗試在'$ form = new CActiveForm();'之前放置小部件代碼嗎?也許有一個id或什麼的問題。我會在家測試你的代碼,也許我會發現問題。 – devOp
我試過了,同樣的問題,好像CJuiDatePicker的庫在這個地方不起作用。 –
你能發佈完整的視圖代碼嗎? – devOp