Can you tell why the call backs in set rules not working if i am using HMVC extention?
here is my controller code.
<?php
/**
* Description of doctor
*
* @author Arif
*/
Class Doctor extends MX_Controller {
function __construct() {
parent::__construct();
$this->load->database();
$this->load->library("my_session");
$this->my_session->checkSession();
}
function appointment_slots()
{
$userid = (int)$this->uri->segment(3);
if($userid <= 0):
redirect(base_url());
die();
endif;
$this->load->model("doctor_model");
$doctor = new Doctor_model();
$dinfo = $doctor->getDoctorInfo($userid);
if(!$dinfo)
{
redirect(base_url());
die();
}
try{
$this->load->library('grocery_CRUD');
/* This is only for the autocompletion */
$crud = new grocery_CRUD();
$crud->unset_jquery();
$crud->set_theme(TABLE_THEME);
$crud->set_table(TBL_APPOINTMENT_SLOTS);
$crud->set_subject('Appointment Slot');
$crud->required_fields(array('day','startTime','endTime','numOfPatients','isActive'));
$crud->columns('day','startTime','endTime','numOfPatients','isActive');
$crud->display_as('day','Day')
->display_as('startTime','Start Time')
->display_as('endTime','End Time')
->display_as('numOfPatients','Number Of Patients')
->display_as('isActive','Active(1 = Active)');
$crud->set_rules("startTime", "Start Time", "xss_clean|trim|required");
$crud->set_rules("endTime", "End Time", "xss_clean|trim|required|callback_checkAppointmentTime");
$crud->set_rules("numOfPatients", "Number of Patients", "xss_clean|trim|required|integer");
$time = time();
$crud->add_fields('day','startTime','endTime','numOfPatients','isActive','userId','creationDtTm','updateDtTm');
$crud->edit_fields('day','startTime','endTime','numOfPatients','isActive','userId','updateDtTm');
$crud->change_field_type('creationDtTm', 'hidden', $time);
$crud->change_field_type('updateDtTm', 'hidden', $time);
$crud->change_field_type('userId', 'hidden', $dinfo->row()->userId);
$output = $crud->render();
$output->dinfo = $dinfo->row();
$output->userid = $output->dinfo->userId;
$output->css = "";
$this->load->library("my_functions");
$output->js = "";
$output->js .= $this->my_functions->addJs("ui/jquery-ui-1.8.18.custom.min.js");
$output->js .= $this->my_functions->addJs("jquery.timepicker.min.js");
$output->pageTitle = "Appointment Slots";
$output->base_url = base_url();
$output->body_template = "appointment_slots_index.php";
$this->load->view("site_template.php",$output);
}catch(Exception $e){
show_error($e->getMessage().' --- '.$e->getTraceAsString());
}
}
function checkAppointmentTime()
{
$starttime = $this->input->post("startTime",true);
$endtime = $this->input->post("endTime",true);
$sArray = explode(":",$starttime);
$eArray = explode(":",$endtime);
if($eArray[0] > $sArray[0])
{
$this->form_validation->set_message("checkAppointmentTime","The %s is greater than the Start time. Please use a valid time.");
return FALSE;
}
if($eArray[0] == $sArray[0]) // hours same
{
if($eArray[1] <= $sArray[1]) // minutes same
{
$this->form_validation->set_message("checkAppointmentTime","The %s is equal to the Start time. Please use a valid time.");
return FALSE;
}
}
return false;
}
}
?>
The callback function checkAppointmentTime is not being called.
I also tried this by changing line 3733 of grocery_crud.php ->
class grocery_CRUD_Form_validation extends MY_Form_validation
still no use.
thanks