Php 类闭包的Yii2对象无法转换为字符串

Php 类闭包的Yii2对象无法转换为字符串,php,yii2,anonymous-function,Php,Yii2,Anonymous Function,我有错误 类闭包的对象无法转换为字符串 关于这个代码 'class' => \dosamigos\grid\EditableColumn::className(), 'attribute' => 'remidi3', 'url' => function($data){return ['update?id=remidi3&dataid'.$data->id];}, 'type' => 't

我有错误 类闭包的对象无法转换为字符串 关于这个代码

'class' => \dosamigos\grid\EditableColumn::className(),
            'attribute' => 'remidi3',
            'url' => function($data){return ['update?id=remidi3&dataid'.$data->id];},
            'type' => 'text',
            'editableOptions' => [
                'mode' => 'inline',
            ]
甚至我也试着改变

'url' => function($data){return ['update?id=remidi3&dataid'.$data->id];}
进入


我需要在可编辑网格的URL中显示id,有人可以帮助我吗?

根据源代码和PHPDoc,您不能在这里指定闭包

PHPDoc说:

/**
 * @var string the url to post
 */
 public $url;
源代码中的用法:

if ($this->url === null) {
    throw new InvalidConfigException("'Url' property must be specified.");
}

...

$url = (array) $this->url;
$this->options['data-url'] = Url::to($url);
如您所见,它被转换为array,然后由进行处理,因此有效类型是string和array


我认为您不需要在url中指定
id
,它应该根据您使用的行自动获取。

我需要id,因为我可以自动获取id,也许可以用另一种方法代替匿名函数?除了将其指定为
字符串
/
数组
之外,没有其他方法。参见文档中的
Url::to()
。了解更多此扩展的工作原理,我非常确定id将自动从您正在使用的行中获取,因为它存储在父级
tr
data pk
属性中。
if ($this->url === null) {
    throw new InvalidConfigException("'Url' property must be specified.");
}

...

$url = (array) $this->url;
$this->options['data-url'] = Url::to($url);