Welcome Guest, Not a member yet? Register   Sign In
Form Validation with a callback function
#1

[eluser]Flying Fish[/eluser]
When I’m using a callback function in a validation rule, can I still add other Codeigniter built in functions?

For example

array(
‘field’ => ‘user_email’,
‘label’ => ‘Email’,
‘rules’ => ‘valid_email|callback_email_check’
),

Will this check if the email is valid first, and then do a db lookup to see if it’s already in the system?
#2

[eluser]TheFuzzy0ne[/eluser]
Yes & yes.
#3

[eluser]Flying Fish[/eluser]
Sweet. I'm using a custom error message if the email address fails the callback function (in other words it already exists in my database).

Is it possible to still use the default form_validation error message for the valid_email check.

What I didn't want to happen is an error message like "this email address is already being used" to show up if it was the valid_email check failed but the callback function was ok? Does that make sense?
#4

[eluser]TheFuzzy0ne[/eluser]
Yes, if the validation for that test fails, a message for that function is loaded, it will says something like: The <INSERT_FIELDNAME_HERE> field must contain a valid email address.

It's loaded from the language file for form validation.

Validation rules cascade. If one fails, no more tests are done for that field.




Theme © iAndrew 2016 - Forum software by © MyBB