如何在 Yii 中通过操作调用 CJui对话

How to call a CJuidialog through action in Yii

本文关键字:操作 调用 CJui 对话 Yii      更新时间:2023-09-26

我正在做一个项目,我需要通过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]

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

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

echo CHtml::button('Delete', array('submit' =>Yii::app()->createUrl("/post/delete", array("id" => $model->id)), 'confirm'=>'Are you sure?', 'name'=>'delte'));