Join Jon Peck for an in-depth discussion in this video Validating user input with the form validation library, part of Up and Running with PHP CodeIgniter (2013).
Now that the two views of the controller have been set up, I now have something…that I can use the Form Validation Library with.…Here's the control flow at a high level. First, I'll load the form_validation library.…Then, I'll set the validation rules for each form element.…When that's complete, I'll execute the validator to see if it passed or not.…With that answer, the application can decide what to do based on validation success.…I'm going to get started by returning to the IDE.…I'll open the magazine controller, and navigate to right before the view is displayed.…
I'll start by loading the form validation library.…So, this, load, library, with a name, form, underscore, validation.…Next I'll call a method called set rules. Set rules takes an array of arrays that…contain three key value pairs. The field which is the form fields name, a…label which is a human readable label that will be shown on failures and rules.…A string containing the names of form validation call back functions.…There's a complete list of validators that ship with CodeIgniter at the following URL.…
Starting with the what and why of CodeIgniter, Jon introduces key concepts such as the MVC pattern and libraries by demonstrating how to create static pages, then storing and displaying magazine info in a database. Advanced topics like classes and helpers are explored to validate user input, upload files, and much more. By creating a complete system, you'll have the foundation to build your own applications with CodeIgniter.
- What is CodeIgniter?
- Creating a static page controller
- Generating output with a view
- What is a model?
- Saving data with Active Records
- Creating forms
- Validating user input
- Listing records in tables
- Uploading images
- Viewing and deleting records