Answer the question
In order to leave comments, you need to log in
Why doesn't it output $dataProved?
Tell me what I'm doing wrong? Need to get related data out of profile...
/**
* Lists all Awards models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new AwardsSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
<?php foreach ($dataProvider->getModels() as $award):?>
<div class="awards-index-card col-sm-4">
<div class="awards-index-img">
<a href="<?= yii\helpers\Url::to(['/awards/view','id'=> $award->id])?>">
<img class="img-responsive" src="<?=$award->getFullImgUrl()?>">
</a>
<div class="awards-social">
<?php
if ($award->profile->vk){
echo Html::a('<i class="fa fa-vk"></i>',$award->profile->vk, ['target'=>'_blank']);
}
if ($award->profile->instagram) {
echo Html::a('<i class="fa fa-instagram"></i>', $award->profile->instagram, ['target'=>'_blank']);
}
?>
</div>
</div>
<div class="awards-info">
<a href="<?= yii\helpers\Url::to(['/awards/view','id'=> $award->id])?>">
<!--<div class="awards-index-title"><?/*=$award->profile->getFullName()*/?></div>-->
</a>
<div class="awards-index-nomination"><?=$award->nomination->name?></div>
<div class="awards-index-year"><?=$award->year?> </div>
</div>
</div>
<?php endforeach; ?>
$award->profile->vk
, but it $award->nomination->name
displays
Answer the question
In order to leave comments, you need to log in
Good evening.
Well, I understand that $dataProvider is not empty, since it displays $award ...
But why is foreach() here?
Isn't it easier to use a ListView?
No, it's not easier, it's even better!
And it will not be necessary to sculpt everything through $dataProvider->getModels(), but already through $model. And connections can be made.
But this already needs to be looked at by SearchModel.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question