Yii 1.1.x: CGridView returns 中的 CbuttonColumn {delete} 使用 POST 错误 400

Yii 1.1.x: CbuttonColumn {delete} in CGridView returns with error 400 using POST

我有以下小部件:

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'feast-days-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
    'day',
    'id',
    array(
        'class'=>'CButtonColumn',
                    'template'=>'{delete}',  
            ),
),
));

过滤器:

public function filters()
{
    return array(
        'accessControl', // perform access control for CRUD operations
        'postOnly + delete', // we only allow deletion via POST request
    );
}

规则:

public function accessRules()
{
    return array(
                    array('allow', 
                        'actions' => array('index','view','create', 'admin', 'delete', 'update'),
                        'roles' => array('master'),
                    ),
                    array('deny', // deny all users
                        'users' => array('*'),
                    ),
    );
}

删除操作:

public function actionDelete($id)
{
     FeastDays::model()->deleteAllByAttributes(array('id'=>$id));
    // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
    if(!isset($_GET['ajax']))
        $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}

我正在使用的 actionDelete 是第无数个,看起来它从未真正达到它。首先我没有唯一的 ID,只有几天,我给了模型 ID,因为我认为这可能会导致我在函数中使用日期作为属性的问题,但结果相同。

我搜索了很多有关此问题的信息,大多数人遇到的问题是某些 .js 文件在 jQuery 之前加载,但在我的 Web 应用程序中 jQuery 首先加载。 其他人的问题是 ajax 使用 GET 而不是 POST,但我已经在 Firebug 中检查了我的请求使用 POST。我什至禁用了 ajax 但没有它我仍然会收到错误 400。

请帮帮我,我迷路了。

我终于自己解决了。看起来它需要一个仅包含整数值的 ID(我尝试使用 uniqid() 为每个日期生成 ID-s 但它仍然抛出错误 400),如果它只获取给 actionDelete() 的整数 ID-s,它工作正常。如果有人知道为什么会这样,我将不胜感激他们的回答,因为我觉得这种情况很奇怪。