First we start with the model layer, mainly to create validation rules, as well as image upload paths and image naming conventions.
Next we want to write good business logic in the controller layer, that is, under what circumstances directly in the call model layer to upload, the general failure or beyond their own provisions will jump page
Finally, let's define the form page! Because the model validation rules have already been written in the rule, it's better to use Yii2 's own form!
In addition, when using Yii2 's own form, be sure to pay attention to the following points:
1. Since the form does not indicate the method of the controller, the approximate meaning is that the name of the form page must be the same as the method name !
2. The Name field of the form is exactly the same as the controller and model settings !
3. The form is written to rule, so you can assign the entire model to the page when you use it directly on the page!
Yii2 Frame native binding frame using picture upload