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
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')); ...
You just need to also use the last parameter of CHtml::link
:
CHtml::link(
'Delete',
array('wsrecruiteducation/delete','id'=>$model->EducID),
array('confirm' => 'Are you sure?')
);
If you wan't a delet Link with confirmation Dialog, use this
echo CHtml::link("Delete", '#', array(
'submit'=>array('controller/delete', "id"=>$model->id), 'confirm' => 'Are you sure you want to delete?'));