D
D
Denis2017-10-09 08:03:10
Yii
Denis, 2017-10-09 08:03:10

How to set model attribute value to variable in controller without form in view?

There are several forms on the view, the values ​​of which are passed to the model attributes (scenario[add]).
It is necessary to set the value of one of the attributes (country_id) equal to a variable, that is, do not create a form for it, but simply hard-link it to the same value for all additions of records to the database.
I'm new to Yii2, please be more detailed... Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-10-09
@qonand

The value of an attribute missing in the form can be set, for example, using the DefaultValidator

A
Alexander Urich, 2017-10-13
@Urichalex

$model->someProperty = 'myValue';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question