将 Yii2 中的渲染命令转换为 smarty

Convert the render command in Yii2 to the smarty

如何在 .tpl 文件中更改此代码?

1)

$ this-> render ('_form', [
     'model' => $ model,
 ]);

2)

GridView :: widget ([
     'dataProvider' => $ dataProvider,
     'filterModel' => $ searchModel,
     'columns' => [
         ['class' => 'yii \ grid \ SerialColumn'],

         'id',
         'title'

         ['class' => 'yii \ grid \ actioncolumn'],
     ],
 ]);

我将数字 2 更改为:

{GridView 'dataProvider'=$dataProvider,'filterModel'=$searchModel,columns=[  
        ['class' => 'yii\grid\SerialColumn'],
        'id',
        'title',
        ['class' => 'yii\grid\ActionColumn'],    ]
 } 

但是这个错误发生了!! : "too many shorthand attributes"

对于网格视图

{GridView::widget([
          'dataProvider' => $dataProvider,
          'filterModel' => $searchModel,
          'columns' => [ 
               ['class' => 'yii\grid\SerialColumn'],
               ['attribute' => 'id'],
               ['attribute' => 'title'],
               ['class' => 'yii\grid\ActionColumn']
          ]
])}

其中 id 和 title 是您的 $dataProvider 的字段 记得在页面顶部使用

{use class="yii\grid\GridView"}

要渲染 tpl 使用:

{$this->render('_form.tpl', ['model' => $Model])}