Tying validation to a form
When a form is first rendered, there is little value in having a form class (such as
Application\Form\Factory, described in the previous recipe) tied to a class that can perform filtering or validation (such as the
Application\Filter\* described in the previous recipe). Once the form data has been submitted, however, interest grows. If the form data fails validation, the values can be filtered, and then re-displayed. Validation error messages can be tied to form elements, and rendered next to form fields.
How to do it...
- First of all, be sure to implement the classes defined in the Implementing a Form Factory, Chaining $_POST Filters, and Chaining $_POST Validators recipes.
- We will now turn our attention to the