8
Creating Forms and Implementing Filters and Validators
This chapter will introduce some Laminas components to handle data input. In this chapter, you will learn how to connect the model layer with the view layer in a controller using laminas-form
, how to filter input data with laminas-filter
, and how to apply validation rules with laminas-validator
.
In this chapter, we’ll be covering the following topics:
- Generating a form for discounts with
laminas-form
- Filtering input data
- Validating input data
At the end of this chapter, you will be able to define HTML forms programmatically using the laminas-form
component. You will also know how to convert input data and remove unwanted (and possibly dangerous) content using the laminas-filter
component. Finally, you will also discover how to validate input data before saving it into a database using the laminas-validator
component.
Technical requirements
All the code related to this chapter can be...