M
M
Michael2019-03-31 21:42:51
Yii
Michael, 2019-03-31 21:42:51

How to display username instead of id?

Hello everybody! I will describe the situation first, there are three tables - documents, doc_sign and user. Documents are loaded into the documents table accordingly, when viewing the document, the user presses the "Acquainted" button, and the document id and user id are written to the doc_sign table. The problem is that in the form of a view related to the documents table, I need to display the username, but it turns out to display only id. I have established a model connection between documents and doc_sign, as well as between doc_sign and user, but I repeat once again, the problem is that I need to display the user name in the form of a documents table. I display user id as follows:

<?php foreach($model->docsign as $key => $value): ?>
    <?= $value->user_id ?>
<?php endforeach; ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-03-31
@Bally

$value->user->name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question