tags:

views:

23

answers:

2

All my previous projects have had this workflow on Contact pages

  1. User submits form
  2. Controller gets $_POST details
  3. Controller validates details (and sets error messages if necessary)
  4. Controller sends email
  5. Controller redirects to thanks page

Is this the standard workflow?

I used to validate everything in controllers, and then did some more reading and they recommended against it. Therefore, should I send the $_POST details to a helper type object and let it do all the work (validation/sending)?

A: 

In controller we should only check validation. The main validation should be on model before operations with DB.

Alexander.Plutov
A: 

The controller file need to check & validate the user input data.

After getting & accumulating all the data, it needs to transfer the data to the Model file for checking with the database (if needed) & then need to do some other works from here (like setting sessions / cookies, or sending mails, or firing hooks, ...). However, the control must come back to the same controller method, as all the previous model functionalities must be fired by a method call, from the same controller method.

The proper view method must be called now, and then the output must be rendered to the console.

Hope it helps.

Knowledge Craving