I am a novice, in the practice of the code encountered a problem is that in the long form to submit data validation, I should put the validation on the controller layer or should be placed in the model layer, this validation includes the judge whether the field is empty, but also to determine the uniqueness of a field and so on. I checked the next, some of the answer is to verify on the controller layer, but TP manual has an automatic verification, this is placed on the model layer, so a little confused forced, I hope that the great God to point.
Reply content:
I am a novice, in the practice of the code encountered a problem is that in the long form to submit data validation, I should put the validation on the controller layer or should be placed in the model layer, this validation includes the judge whether the field is empty, but also to determine the uniqueness of a field and so on. I checked the next, some of the answer is to verify on the controller layer, but TP manual has an automatic verification, this is placed on the model layer, so a little confused forced, I hope that the great God to point.
Give you a manual link, hoping to help you to automatically verify
You can test the data according to the validate defined in model before automatically creating the data $this->create () on the model layer. Personally, encapsulation is better. This is called dynamic validate.
The project I am writing is in the controller.