V
V
Vitaly2017-06-12 09:37:56
Yii
Vitaly, 2017-06-12 09:37:56

Get model in layout?

Good morning. There are many different models. For users for companies, etc.
There is in layout main.php which is responsible for displaying pages. How can I refer to the company model in this file, for example?
tried like this

<?
$model = new Company();
?>

but when displaying the result, I do not see the fields that should be present there

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-06-12
@kat-vetal

How can I refer to the company model in this file, for example?

It is not necessary to access models at the layer level, this is bad practice. It's better to create a widget for this task
Namely fields or data? if fields - then show how you enter, if data - then they can not be, tk. You CREATE a model that has no data by default.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question