How to create a link with confirmation dialog using Yii?

前端 未结 3 640
误落风尘
误落风尘 2021-01-01 16:52

How can I create a link with a confirmation dialog in Yii framework?

Let\'s say I have

CHtml::link(\'Delete\',array(\'wsrecruiteducation/delete\',\'i         


        
3条回答
  •  余生分开走
    2021-01-01 17:14

    you can do something like this:

    CHtml::link(
        'Delete',
        '#',
         array('submit'=>array('wsrecruiteducation/delete','id'=>$model->EducID),
               'params'=>('returnUrl'=>'controller/action...'), 'confirm' => 'Are you sure?')
    );
    

    The returnUrl will be a post item sent with the request, make sure you make something like this in a controller with delete action:

    ...
    if(!isset($_GET['ajax']))
         $this->redirect(isset($_POST['returnUrl']) ? array($_POST['returnUrl']) : array('admin'));
    ...
    

提交回复
热议问题