1. Assume there is a form
Note: __SELF__ returns the path of the method where the controller is located. You can print echo __SELF__ in the controller method;
You can check whether {$smart.const.__SELF__} has been parsed through firebug
2. Collect form data
Method 1. Through $_POST method
The data $_POST received in the controller is an array, and then you can add the form through the add() method Data.
Method 2. Through AR, it is more flexible
Because some data do not want to be stored in the database , all data can be added in this way.
Method 3. Through the create() method, note that this method is only responsible for helping us collect data, but does not help us add data to the database.
Note: If we write the name attribute in the form incorrectly, for example:
There is no such name in the data table goods_number_number field, the create() method will automatically filter out this field for us.
How to filter in the specific framework?
When we add the database successfully, we need to return to the add page. The above way of writing is too ugly. We can call $this-> ;success('prompt information','generate URL address through U function'); and$this->error('error prompt information','url address')