Hello,
How can I change a value before validate? I know I can use the "before insert callback", but its need to pass validation first.
Example: My form has 3 fields "Name, Email, User", they are mandatory for the database, but the User is optional. If is empty, i want to use the value inside Email as a user.
$crud->fields('name',email','user');
How to do that? I need to use my validation rules: (Email and User rules are similar)
$crud->set_rules('user','User','required|is_unique[user.user]|_callback1|_callback2');
If I use before insert, doenst work, validation says "User is required"
$crud->callback_before_insert(array($this,'_default_user_callback'));
			
function _default_user_callback($post_array){
 if($post_array['user'] == ''){
  $post_array['user'] = $post_array['email'];
 }
 return $post_array;
}
I have to break the validation? can I use the user as "invisible" and later add the value?
Thanks for any advice.
