Twitter bootstrap 如何在Yi2上的Collapse::widget中处理任意关系

Twitter bootstrap 如何在Yi2上的Collapse::widget中处理任意关系,twitter-bootstrap,widget,yii2,has-many,collapse,Twitter Bootstrap,Widget,Yii2,Has Many,Collapse,我在我的系统上使用yii2制作的一个小票证模块,这些票证由注释组成,我想在每个票证的摘要中使用折叠小部件yii2(http://www.yiiframew.com/doc-2.0/yii bootstrap Collapse.html)显示关联注释的列表,但我发现以下错误:尝试获取非对象的属性 型号 票 注 查看 Collapse::widget([ 'items' => [ [

我在我的系统上使用yii2制作的一个小票证模块,这些票证由注释组成,我想在每个票证的摘要中使用折叠小部件yii2(http://www.yiiframew.com/doc-2.0/yii bootstrap Collapse.html)显示关联注释的列表,但我发现以下错误:尝试获取非对象的属性

型号

查看

Collapse::widget([
                   'items' => [
                        [
                        'label' => $model->notes->subject,
                        'content' => $model->notes->content,
                        ],
                    ]
                 ]);

尝试反复浏览注释:

$notes= [];

foreach($model->notes as $note) {
  $notes[] = [
    'label' => $note->subject,
    'content' => $note->content,
  ];
}
然后将注释分配给小部件:

Collapse::widget(['items' => $nodes]);
希望有帮助:)

$notes= [];

foreach($model->notes as $note) {
  $notes[] = [
    'label' => $note->subject,
    'content' => $note->content,
  ];
}
Collapse::widget(['items' => $nodes]);