L
L
Leopandro2017-10-02 17:33:18
Yii
Leopandro, 2017-10-02 17:33:18

Updating model with image in yii2?

Here I have a model in which there is an image (mandatory attribute) $model->image_file.
When we update a model with an image, it turns out that image_file is empty and a validation error occurs.
How can I make sure that the file is refilled during the update so that this does not happen?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-10-02
@webinar

image_file you should contain not a file, but a string, a file name. And for the file add 1 more attribute, for example file.
Then there will be no errors and validation will work normally, for the file separately and for its name separately

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question