Welcome Guest, Not a member yet? Register   Sign In
Please help me. How to validation 2 fields in form using Call Back in validation?
#1

[eluser]Unknown[/eluser]
Hi guys, in CI form validation we can validate a field with a Call back function in set_rules(), but this call back is associated with one field only.
I have a registration form that has first name and last name field. I want to check if both first and and last name is in DB, then return false, because 2 people with the same first and last name cannot register, so I want to check DB to see if first and last name is already there. I want to use the call back feature in form validation. Can you please help me?
I appreciate your help.
#2

[eluser]jairoh_[/eluser]
look here -> http://ellislab.com/codeigniter/user-gui...#callbacks

instead of
Code:
if ($str == 'test')

check the last and first name redundancy in your database.
#3

[eluser]Unknown[/eluser]
[quote author="jairoh_" date="1370226941"]look here -> http://ellislab.com/codeigniter/user-gui...#callbacks

instead of
Code:
if ($str == 'test')

check the last and first name redundancy in your database.[/quote]

Thanks for your reply. In this example, the call back function is in Controller, but if I want to check if first and last name is in DB, I need to have my function in Model because all my database codes are in Model.
Do you think the call back function has to be in Controller?




Theme © iAndrew 2016 - Forum software by © MyBB