Answer the question
In order to leave comments, you need to log in
Yii2 how to assign label to DynamicModel?
Hello.
Created a dynamic model for the form in Yii2.
Everything works fine, but the field label is listed as " Phone ".
Following the doc, I decided to write attributeLabels .$model = new \yii\base\DynamicModel(['phone']);
$model->attributeLabels(['phone' => "Номер телефона"]);
Answer the question
In order to leave comments, you need to log in
DynamicModel is used for dynamic validation. If you want to use labels, then make a regular model.
The attributeLabels() method is only used to get the labels of the attributes specified in the class.
It can be like this, for example:
$form->field($model, 'phone')->textInput()->label('Номер телефона');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question