0

我正在做一个项目,我需要通过 actionCreate 调用我的 CJuidialog。有没有办法做到这一点?我只想有一个简单的对话框,其中包含一些文本和按钮,如果满足我的条件,则提交和取消。这是我已经开始的。

public function actionCreate()
{
    $model=new EmpSched;

    // Uncomment the following line if AJAX validation is needed
    // $this->performAjaxValidation($model);

    if(isset($_POST['EmpSched']))
    {
        $model->attributes=$_POST['EmpSched'];
        if($model->default==1){

            Yii::app()->clientScript->registerScript('my_script', 'alert("Hi     there!");', CClientScript::POS_READY);

        }else{
            ($model->save());
                $this->redirect(array('view','id'=>$model->id_empsched));
        }

    }

    $this->render('create',array(
        'model'=>$model,
        'emp'=> new CActiveDataProvider('schedule'),
    ));
}

这是输出:

![在此处输入图像描述][1]

我遇到的问题是我无法在 actionCreate 中调用 CJuidialog。我想做如果它满足我的条件显示对话框,如果不只是保存。

4

1 回答 1

0

在 yii 中 htmlOptions 中有一个确认键:

echo CHtml::button('Delete', array('submit' =>Yii::app()->createUrl("/post/delete", array("id" => $model->id)), 'confirm'=>'Are you sure?', 'name'=>'delte'));
于 2013-09-18T10:34:42.947 回答