Yii2 Frame native binding frame using picture upload

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.