且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误 400 删除记录的无效请求 YII

更新时间:2022-01-28 07:34:36

发生这种情况是因为它不是发布请求.CHtml::link 有一种方法可以使用 post 方法,而不是 get.这需要您使用 clientChangesubmit 属性>,在你的 htmlOptions 中.

This is happening because it's not a post request. CHtml::link has a way by which you can use post method, instead of get. This requires you to use submit attribute of clientChange, in your htmlOptions.

有点像这样:

echo CHtml::link(CHtml::encode('Delete image'), array('image/delete', 'id'=>$image->id),
  array(
    'submit'=>array('image/delete', 'id'=>$image->id),
    'class' => 'delete','confirm'=>'This will remove the image. Are you sure?'
  )
);