Posts

Showing posts with the label form validation

CodeIgniter - Extending Form Validation

Overview 1. Store all form validation in application/config/form_validation.php 2. Create a library to extend form validation for callback functions 3. Run the form validation inside the controller method Step 1: Create form_validation.php Create the file application/config/form_validation.php then add your form validations In my example, I’ll do something like the code below which validates the inputs when a user creates a news article $config = array( 'article' => array( array( 'field' => 'news_title', 'label' => 'Title', 'rules' => 'trim|required|max_length[100]' ), array( 'field' => 'news_body', 'label' => 'Body', 'rules' => 'trim|required' ), array( 'field' => 'news_category', 'label...