Welcome Guest, Not a member yet? Register   Sign In
Problems with extending CI_Form_validation
#4

(This post was last modified: 07-30-2017, 02:12 AM by Martin7483.)

Problem 1:

PHP Code:
$this->form_validation->set_rules('email''''scanEmail|required');
var_dump($this->form_validation->run()); // ALWAYS RETURNS FALSE 

You have set two rules, but if you post an empty form then
Rule 1, scanEmail, will return TRUE
Rule 2, required, will return FALSE
And that causes $this->form_validation->run() to return FALSE

Don't only var_dump() the run method.
Place a var_dump() in each rule method that should run and var_dump the passed in arguments. That way you can see if it even reaches a rule or not.

Problem 2:
You should set the messages when setting the rules. I think because you are doing it only when the rule fails it can't find the message.

PHP Code:
$this->form_validation->set_rules('email''Field Label''scanEmail|required',
 
   array(
 
       'required' => 'Email address is mandatory'
 
       'scanEmail' => 'Do not use special chars'
 
   )
); 
Reply


Messages In This Thread
RE: Problems with extending CI_Form_validation - by Martin7483 - 07-30-2017, 02:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB