-
Book Overview & Buying
-
Table Of Contents
concrete5 Cookbook
When building an application that accepts user data, it is definitely a good idea to make sure that users are filling out all of the required fields on a form.
Consider a comment form that has the following fields: Name, Email, Website, and Comment content. The name, e-mail, and content fields are required, but the website field is optional. We will use the Validation helper to determine if the user filled out all of the required fields.
Load the Validation helper:
$val = Loader::helper('validation/form');Let's create an array to simulate the data that would be contained in the POST request (via the $_POST super global). We will intentionally leave email blank to see how the Validation helper behaves when a test fails:
$data = array( 'name' => 'Jane Doe', 'email' => '', 'website' => 'http://example.com', 'content' => 'Great post!' );
Pass the array to the Validation helper so that it knows what...
Change the font size
Change margin width
Change background colour