[eluser]ggoforth[/eluser]
[quote author="David Johansson" date="1248415823"]what are you doing diffrent in the controller where it won't work? it sounds like you have some problem setting the rules...[/quote]
Absolutely nothing that I can see. Standard controller, the validation lib is auto loaded, and I copied and pasted the code for set_rules() from the controller where it's working fine (and changed the field names). I'm totally stumped. I've literally gone line by line, I'll post some code, but I can't see where the problem my be. The function in question is "run_reg".
Code:
<?
class Booker extends Controller{
public function __construct(){
parent::Controller();
$this->load->model('booker_model');
$this->load->model('contractor_model');
}
public function index($provider = NULL){
$data = NULL;
if(!is_null($provider)){//we have a provider
if($this->_provider_exists($provider)){//and the provider exists
//set the provider contractor_id
$contractor = $this->contractor_model->get_contractor_by_username($provider);
$this->dbsession->set_userdata(array('provider_id'=>$contractor['contractor_id'],'provider'=>$provider));
$this->viewloader->booker_render('login_register_view',$data,$provider);
}else{//and the provider does not exists
$this->viewloader->direct_render('/booker/no_provider',$data);
}
}else{//we dont' have a provider
$this->viewloader->direct_render('/booker/no_provider',$data);
}
}
public function run_reg(){
$this->form_validation->set_rules('fname','First Name','required|trim');
$this->form_validation->set_rules('lname','Last Name','required|trim');
$this->form_validation->set_rules('email','Email','required|trim|valid_email');
$this->form_validation->set_rules('phone','Phone','required|trim');
$this->form_validation->set_rules('password','Password','required|trim');
if($this->form_validation->run() == false){
echo json_encode(array('error'=>'true','errormsg'=>validation_errors()));
}else{
}
}
private function _provider_exists($provider){
if($this->contractor_model->provider_exists($provider)){
return(true);
}else{
return(false);
}
}
}
?>
This function is used as a ajax call, and returns json to my calling javascript function. However even if I access the file directly, I'm still not getting any error output.
Thanks for taking a look!
Greg