Welcome Guest, Not a member yet? Register   Sign In
Combine the form_validation config file with rule callback functions
#1

[eluser]cjke[/eluser]
Hi guys,

I'm putting together a registration page. I need to add a custom callback function to validate names (rule:alpha would almost work but need to include ' for names like o'leary).

If I create a set of rules and the call back all in my controller the following works:

Code:
array(
    'field'   => 'first_name',
    'label'   => 'First Name',
    'rules'   => 'required|callback_valid_name'
)

function valid_name($s) {
    // return true or false depending, etc
}

BUT I would like to store it in the form_validation config file. The required etc is fine, but the callback never gets called. I believe the rule can't find the function. However it will work if I put the valid_name function in the controller. So where can I put the custom functions so the config file rule set can find them??

Thanks


Messages In This Thread
Combine the form_validation config file with rule callback functions - by El Forum - 01-23-2011, 05:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB