How do popular PHP frames handle form input errors?

I know, for example, that the Zend Framework has some ability to create form elements using validators. But now, let's say a user enters full garbage data, which is invalid. What will happen next? Suppose that part of JS is erroneous or JS is disabled, and the server receives garbage data.

How do "large" PHP frameworks "conceptually" handle? Please indicate the structure and describe it if you know. This will help a lot.

How are error messages returned to the form and how are they displayed? How is this done technically?

From my point of view, theoretically, this should go as follows:

  • User enters trash
  • User submits form (JS verification is not performed, JS is deactivated, whatever)
  • PHP script gets garbage input
  • PHP script verifies server side garbage input. All fields = FALSE, GARBAGE.
  • Each time a field check is performed, the PHP script writes an input error message to the array.
  • an array of error messages is a map (associative array), where the key is the name of the form element
  • Script loads form again due to input errors
  • The script form has all the logic for displaying field input errors from an array of error messages
  • The user sees beautiful error messages and re-enters the garbage.
  • Again and again.
  • So far so good> the script saves the data and displays a message of large THANKS messages.

I do not know another, but if there is, I need to know; -)

Something tells me that this is not the best solution.

+3
1

, -, Dojo, Zend Framework javascript. JS , Dojo.

ZFE Validator. , ZFE . , , Zend_Form_Decorator_Errors, "" .

Zend_Form, isValid(). , .

+2

Source: https://habr.com/ru/post/1727936/


All Articles