php - Only Codeigniter callback function is working rest validation rules are being ingnored

I have a simple registration page where a small validation whether CPF Number exist or not is to be checked from database along with some validation rules. However after submitting the form only callback function is working from the validation rules and rest rules are being ignored like required|trim... etc.
In My Controller (Validation Rules):
if ($this->input->post()) {
$this->form_validation->set_rules('cpf','CPF','trim|required|numeric|max_length[15]|callback_checkIfExist[cpf]');
if ($this->form_validation->run()==TRUE) {
$rb = random_bytes(8);
$randPass = bin2hex($rb);
// TODO: Store hashed password in db
// mail new password for login
// login and update password
}
}
$this->load->view($page,$data);
In My Controller (Callback Function):
public function checkIfExist($cpf){
if (!$data['employee']=$this->HomeModel->getEmployeeData($cpf)) {
$this->form_validation->set_message('checkIfExist','No data found with this {field}');
return false;
} else {
return true;
}
}
In My Model :
public function getEmployeeData($cpf){
# returning only 1 row of particular employee
$this->db->where('e_cpf',$cpf);
$this->db->where('e_b_id',Me::$bid);
$qry = $this->db->get('employees');
if ($row = $qry->row()) {
return $row;
}
}
In My View :
<form class="user" action="" method="post">
<div class="form-group">
<input type="text" name="cpf" class="form-control form-control-user <?=(form_error('cpf'))?'is-invalid':'is-valid'?>" id="exampleInputEmail" aria-describedby="emailHelp" placeholder="Enter CPF Number ..." value="<?=set_value('cpf')?>">
<p class="p-2"><?=form_error('cpf')?></p>
</div>
<input class="btn btn-primary btn-user btn-block" type="submit" name="register" value="Register">
</form>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: to enable extensions, verify that they are enabled in your .ini files
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.