tresrob
(Tresrob)
1
Hi, I am new to yii2
please someone can help me, how i can display in detailview a value of a relate table.
As the following example i want show in listview/detailview name of client not id of order
Thanks
Example
Table example
Order:
id
client_id (relate to Client–id_client
date
…
Client:
id_client
name
…
Thanks in advance
Bizley
(Bizley)
2
If you set the relation (method getClient() in Order) you can set the value of attribute like this:
echo DetailView::widget([
'model' => $model,
'attributes' => [
[
'label' => 'Client name',
'value' => $model->client->name,
],
],
]);
tresrob
(Tresrob)
3
Thank you very much!!!!
This works perfectly in view - DetailView::widget([ but as I want to see client-name also in index - GridView::widget([
Thanks again