错误400删除记录的无效请求YII [英] Error 400 Invalid request YII for deleting a record
问题描述
我正在尝试删除Yii中的一条记录,这将引发错误400.请不要再次重复此请求.它正在检查post变量,我的控制器文件有
if(Yii::app()->request->isPostRequest)
当我回显post变量时,它为空,而$ _GET具有要删除的ID,我的View文件看起来像>
I am trying to delete a record in Yii, which throws a Error 400. Please do not repeat this request again. It's checking for a post variable, my controller file has
if(Yii::app()->request->isPostRequest)
When I echo my post variable it's blank whereas $_GET has the id which I want to delete, my View file looks like,
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?'));
访问规则已删除给已验证的用户,这是正确的.也尝试过*. 我还尝试将其作为隐藏变量发送,但效果不佳.
The access rules has delete to authenticated users, which is right. Tried it with a * too. I also tried sending it as a hidden variable but no good.
无法弄清楚我应该如何在Yii中发布表格.
Not able to figure out how should I post a form in Yii.
推荐答案
之所以发生这种情况,是因为它不是发布请求. CHtml::link
提供了一种使用post方法而不是get的方法.这要求您在clientChange
的submit
属性>.
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?'
)
);
这篇关于错误400删除记录的无效请求YII的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!