[[+content_image]]
L
L
LucasP2017-09-21 18:26:01
Yii
LucasP, 2017-09-21 18:26:01

Yii2 file required?

There is a model with several fields, but the file is the only one required. How to implement it?

public $name;

    public function rules()
    {
        return [
            [['name'], 'required', 'on' => ['create','update']],
 ...
            [['file'], 'file'],
        ];
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question