YII 调用delete action 会出现Bad Request Your request is invalid.

php中文网
发布: 2016-06-23 14:13:04
原创
1494人浏览过

// view 下的  
$v): ?>


user_id; ?>
user_name; ?>
user_realname;?>
user_password;?>
user_sex; ?>
user_roles; ?>
user_birthday; ?>
user_relation; ?>
dep_id; ?>
user_address; ?>
user_allowed; ?>
user_createtime); ?>
user_lasttime; ?>
createUrl('/parkuser/view',array('id'=>$v->user_id)) ?>">查看
createUrl('/parkuser/update',array('id'=>$v->user_id))?>">修改
createUrl('/parkuser/delete',array('id'=>$v->user_id))?>">删除





//问题在三个操作上边    查看 修改都可以用   唯独删除不行

//delete action


class DeleteAction extends Publics{


/**
 * Deletes a particular model.
 * If deletion is successful, the browser will be redirected to the 'admin' page.
 * @param integer $id the ID of the model to be deleted
 */  
public function run(){

$this->delete();
}
public function delete(){
$id = intval($_GET['id']);

$model=ParkUser::model()->findByPk($id);
if($model===null) die("");
$model->delete();

// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->getController()->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
}

?>

回复讨论(解决方案)

$model->delete();

的时候没有把id传入进去。

以前在维护网站的时候发现如果某个js传漏了,或者错误都可能导致这种删除删不掉的情况,遇到过一次,重新传资源

id 传过去了    地址栏变化为:http://localhost/park/index.php?r=parkuser/delete&id=11

补充一下  controller  求牛人解决下 

public function actions(){
return array(
'captcha'=>array(
'class'=>'CCaptchaAction',
'backColor'=>0xFFFFFF,
),

'page'=>array(
'class'=>'CViewAction',
),
'create'=>'application.controllers.parkuser.CreateAction',
'update'=>'application.controllers.parkuser.UpdateAction',
'view'=>'application.controllers.parkuser.ViewAction',
'index'=>'application.controllers.parkuser.IndexAction',
'admin'=>'application.controllers.parkuser.AdminAction',
'delete'=>'application.controllers.parkuser.DeleteAction',
);

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号