我像这样创建新widget
的:
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));
}
}
view
为此widget
:_
<?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>
在这种情况下,日历不会打开,但是当我CJuiDatePicker
在简单视图中使用时,它datepicker
可以正常工作。