Welcome Guest, Not a member yet? Register   Sign In
Extend form validation class and add custom validation rules in codeigniter
#1

[eluser]levani[/eluser]
What I'm trying to do is to extend the form validation class and add some custom validation rules there, but for some reasons codeigniter can't see any of them...

I have created new file inside libraries folder called MY_Form_validation.php and added the following code:

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation {

    function valid_date($str)
    {
        return FALSE;
    }

}
But the validation_errors() function never returns any errors (I have stored the error message in config folder), if I place valid_date function inside a controller it works fine. Any ideas?
#2

[eluser]CroNiX[/eluser]
From the userguide:
Quote:All of the native error messages are located in the following language file: language/english/form_validation_lang.php

To set your own custom message you can either edit that file, or use the following function:
$this->form_validation->set_message('rule', 'Error Message');




Theme © iAndrew 2016 - Forum software by © MyBB