Hi,
I have two model, Card (related to db table card, pk card_id) with all mandatory fields and Card_front (related to db table card_front, pk card_id) with the optional fields such as the card’s image, store in the db field card_front as a path.
Card.php model
public function getCardFront()
{
return $this->hasOne(Card_front::className(), ['card_id' => 'card_id']);
}
in the card view, I show attribute also of card_front table :
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'card_id',
// this display the card image
['attribute'=>'cardFront.front_path',
'label'=> 'Card Front',
'format'=>'image'],
//other attributes
],
]) ?>
as no all cards have an entry in card_front table, is there a way to display an url (e.g. Card Front
index.php?r=card_front%2Fcreate) instead of the default Card Front (not set) in the card view?
Thank you