php - How to call another DetailView::widget from another model in one view YII2? -


i new in yii2. have display data table in detailview::widget.

i want call detailview::widget table , display in same view.

you can use 2 detailview widgets in same view, there no problem.

in controller:

use yii\web\notfoundhttpexception;  ...  public function actionview($id) {     $model1 = $this->findmodel($id);     $model2 = modelname::find()->where(['id' => ...])->one();     if (!$model2) {         throw new notfoundhttpexception('second model not found');     }      return $this->render('view', [         'model1' => $model1,         'model2' => $model2,     ]); } 

in view:

<div class="col-md-6">     <?= detailview::widget([         'model' => $model1,         'attributes' => [             'name',         ],     ]) ?>     </div>  <div class="col-md-6">     <?= detailview::widget([         'model' => $model2,         'attributes' => [             'name',         ],     ]) ?> </div> 

more info on detailview widget.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -