I just started building the admin panel using this awesome library.
In this admin panel the admin has the privilege to create & update username of an individual.
Therefore , for validation of an email , I am using CI's form validation library
$crud->set_rules('Email','Email','required|'valid_email'|is_unique[User.Email]');
The above line of code works well when creating username .
The problem occurs when i am UPDATING the same user and when i hit the UPDATE BUTTON I get the following error "Email field must be unique"
As you can guess the form validator is firing the same query when state is 'edit'
i also tried using the getState() but it doesn't seems to work
$state = $crud->getState();
if($state == 'add'){
$crud->set_rules('Email','Email','required|is_unique[Employee.Email]');
}
Can one suggest me a different approach to solve this .