【发布时间】:2015-06-24 12:38:20
【问题描述】:
在 Yii 中工作,我得到了
的错误SystemManagementController 及其行为没有方法或 名为“createReturnableUrl”的闭包
我找不到任何解决方法。它发生在我添加这个之后:
array(
'class' => 'CButtonColumn',
//'viewButtonUrl' => '$this->grid->controller->createReturnableUrl("view",array("id"=>$data->id))',
'updateButtonUrl' => '$this->grid->controller->createReturnableUrl("update",array("id"=>$data->id))',
'deleteButtonUrl' => '$this->grid->controller->createReturnableUrl("delete",array("id"=>$data->id))',
//'deleteConfirmation' => Yii::t('app', 'Are you sure to delete this item?'),
),
到:
<?php
//The following lines needs to be moved to the controller to sepparate the view from the controllers.
$model = new CActiveDataProvider('User');
//The following line should be set by the controller. Containing the names of the colums in a chosen language.
/**/
$colums = array(
'login',
'name_first',
'name_last',
//'password',
'email',
'is_active',
//'sortorder',
array(
'class' => 'CButtonColumn',
//'viewButtonUrl' => '$this->grid->controller->createReturnableUrl("view",array("id"=>$data->id))',
'updateButtonUrl' => '$this->grid->controller->createReturnableUrl("update",array("id"=>$data->id))',
'deleteButtonUrl' => '$this->grid->controller->createReturnableUrl("delete",array("id"=>$data->id))',
//'deleteConfirmation' => Yii::t('app', 'Are you sure to delete this item?'),
),
);
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model,
'columns' => $colums,
'filter' => $model->model)
);
?>
当我删除那段代码时,没有问题,一切正常,但是当我添加该行时,它给了我错误。
我在不同的班级也使用了那条线,但我没有遇到问题,我该如何解决这个问题?
【问题讨论】:
-
尝试转义 $,这可能会解决它。
-
@MihaiP。我确实删除了它现在可以使用的 $ 但我收到此错误
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /vagrant/vendor/yiisoft/yii/framework/base/CComponent.php(612) : eval()'d code on line 1 -
其他使用这个的控制器,它们(包括问题控制器)是否都扩展了同一个类?
-
嗯,它们没有显示任何错误。