Welcome Guest, Not a member yet? Register   Sign In
Custom validation is not being called on production server but works on localhost
#19

[eluser]neal789[/eluser]
I've been having a similar problem to "vanquish". Custom validation rules aren't working on my development server however they are working on my local MAMP server. The big difference between my problem and Vanquish is that the custom validation file (ie. MY_Form_validation.php) is being included. It even works on the development server if I overwrite a stock CI validation rule. For example I can overwrite the required() function in MY_Form_validation.php and it works perfectly. However when I create a new rule it doesn't seem to see it. I don't get an error either. Nothing happens. It just seems to skip that validation item.

So for one particular form field I have the following validation rules
Code:
// A Snippet from my form validation config file.
...
                        array(
                            'field'    =>    'email_addresses',
                            'label'    =>    'Email Addresses',
                            'rules'    =>    'trim|required|valid_emails|max_emails[3]'
                            ),
...

So for the email_addresses field, "required" validates correctly, even if I overwrite the native CI rule with a custom rule. Valid_emails rule also validates correctly. However the "max_emails" rule seems to be ignored as if it weren't there, but only on my development server. On my local MAMP server it works perfectly.

Here is the max_emails function:
Code:
...
function max_emails($str, $val)
    {
        log_message('debug','MAX EMAILS: '.$str.' '.$val);
        if (strpos($str, ',') === FALSE)
        {
            return TRUE;
        }
        
        $i=0;
        foreach(explode(',', $str) as $email)
        {
            if (trim($email) != '' && $this->valid_email(trim($email)) !== FALSE)
            {
                $i++;
                if($i>$val) return FALSE;
            }
        }
        
        return TRUE;
    }
...

Whatever the problem is, it doesn't seem to be specific to this rule since I'm having the same problem with a different custom validation rule on a different development branch.

Any thoughts/help/solution would be greatly appreciated.

Cheers,
Neal


Messages In This Thread
Custom validation is not being called on production server but works on localhost - by El Forum - 08-01-2010, 11:03 AM



Theme © iAndrew 2016 - Forum software by © MyBB