0

我像这样创建新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可以正常工作。

4

1 回答 1

0

尝试使用$this->getController()->widget('zii.widgets.jui.CJuiDatePicker', array(....));.

于 2016-07-14T13:11:27.417 回答