Создал свою библиотеку для добавления новых пользователей.
class Register
{
private $CI;
public function add_new_user()
{
$CI =& get_instance();
$CI->form_validation->set_rules('email', 'Email', 'required|callback_is_email_exist');
if ($CI->form_validation->run() == TRUE)
{
$email = $_POST['email'];
$insert_data = array('email' => $email);
$CI->new_data->add_user($insert_data);
}
}
private function is_email_exist($email)
{
$CI =& get_instance();
$email_result = '';
$query = $CI->check->find_email($email);
foreach ($query->result_array() as $row)
{
$email_result = $row['email'];
}
if ($email_result == $email)
{
$CI->form_validation->set_message('is_email_exist', 'Such email already exist!');
return FALSE;
}
else
{
return TRUE;
}
}
}
Настроил автозагрузку для form_validation и моделей check, new_data. При отправке формы на месте где должны выводиться ошибки(если они есть),выводится Unable to access an error message corresponding to your field name Username.(is_username_exist). Как сделать чтобы выводилась правильное сообщение об ошибке?