Answer the question
In order to leave comments, you need to log in
How to work with activeFom in yii 2?
Tell me how to do it right. In the form I receive data from the form, they are loaded into the controller. I need to set a default inputText value and add the data received from the form to it.
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->images = 'Default!!!!' + data received from the form
How ?
}
Answer the question
In order to leave comments, you need to log in
If you need to change the value, then validate and save:
if ($model->load(Yii::$app->request->post())) {
$model->images = 'some value' . $model->images;
$model->save()) {
//Save logic
}
}
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->images = 'some value' . $model->images;
$model->save(false)) {
//Save logic
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question