validation error is not showing. This is my update function.
public function index_put($id)
{
try
{
$input = $this->put();
if($input)
{
$this->form_validation_update();
if($this->form_validation->run() == FALSE)
{
$this->error_msg();
}
else
{
if($this->db->update('admins', array('id'=>$id))){
$this->update_msg();
}
else{
throw new Exception("The Data Already Register or The Data is Empty");
}
}
}
}
catch (Exception $e)
{
$error = array($e->getmessage());
$errormsg = json_encode($error);
echo $errormsg;
}
}
and now this is my validation query function:
public function form_validation_update()
{
$this->form_validation->set_rules('fname','First Name','trim|required|max_length[128]|xss_clean|alpha');
$this->form_validation->set_rules('lname','Last Name','trim|required|max_length[128]|xss_clean|alpha');
$this->form_validation->set_rules('email','Email','trim|required|valid_email|xss_clean|max_length[128]');
$this->form_validation->set_rules('username','User Name','trim|required|max_length[128]|xss_clean');
$this->form_validation->set_rules('phone_no','Phone Number','required|min_length[6]|xss_clean|numeric');
$this->form_validation->set_rules('role_id','Role','trim|required|numeric');
$this->form_validation->set_rules('address_line_1','Address','required|xss_clean');
}
and now this is error message showing function for update query.
public function error_msg()
{
$error = $this->form_validation->error_array();
$errormsg = array(
'code' => 6,
'msg' => 'Details provided are not valid. Please enter valid details.',
'data'=> array('validation_errors' => $error)
);
echo(json_encode($errormsg));
echo '<pre>';
print_r($error);
die();
}
and this output is
{"code":6,"msg":"Details provided are not valid. Please enter valid details.","data":{"validation_errors":[]}}
update function is called but not giving data of form validation. and i also what validation for unique check email is already register or not but not in that id when data is updating