我试图在 Yii 中删除一条记录,这会抛出错误 400。请不要再次重复此请求。它正在检查后变量,我的控制器文件有
if(Yii::app()->request->isPostRequest)
当我回显我的 post 变量时,它是空白的,而 $_GET 具有我想要删除的 id,我的视图文件看起来像,
echo CHtml::link(CHtml::encode('Delete image'), array('image/delete', 'id'=>$image->id), array('class' => 'delete','confirm'=>'This will remove the image. Are you sure?'));
访问规则已删除经过身份验证的用户,这是正确的。也用 * 尝试过。
我也尝试将其作为隐藏变量发送,但效果不佳。
无法弄清楚我应该如何在 Yii 中发布表单。
发生这种情况是因为这不是一个帖子请求。CHtml::link
有一种方法可以使用 post 方法,而不是 get 方法。这需要你使用submit
的属性clientChange http://www.yiiframework.com/doc/api/1.1/CHtml#clientChange-detail, 在你的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?'
)
);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)