I know for example the Zend Framework has some capability for creating form elements with validators. But now, lets say the user enters complete garbage data, which is invalid. What would happen next? Lets say the JS part goes wrong or JS is disabled, and the server receives the garbage data.
How do the "big" PHP frameworks handle this, conceptually? Please mention the framework and describe it, if you know. That would help a lot.
How are the error messages returned to the form and how are they displayed? How is that done technically?
From my point of view, in theory it has to go this way:
- User enters Garbage
- User submits the Form (JS validation fails, JS deactivated, whatever)
- PHP script receives garbage input
- PHP script validates garbage input on server side. All fields = FALSE, GARBAGE.
- Every time a field validation fails, the PHP script writes an input error message into an array.
- Error Message array is a map (associative array) where the key is the form element name
- Script loads the form again because of input errors
- Form script has all the logic to display the field input errors from the Error Message array
- User sees beautiful error messages and re-enters garbage.
- Over and over again.
- Until everything is all right > script saves the data and displays big THANKS message.
I know of no other, but if there is, I need to know ;-)
Something tells me this is not the best solution.