⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Problem in callback_insert



Revshare Lanuza
  • profile picture
  • Member

Posted 31 July 2013 - 02:55 AM

Please help me 

when im using the callback_insert 

The date is not inserting to my database what should be the problem is this a bug?


Revshare Lanuza
  • profile picture
  • Member

Posted 31 July 2013 - 03:08 AM

this is my code in my controller

 

function student($operation = null)
{
$this->grocery_crud->set_table('tblstudent');
$this->grocery_crud->unset_columns('image');
$this->grocery_crud->set_subject('Student');
$this->grocery_crud->fields('StudentNumber','CourseID','FirstName','LastName','MiddleName','Birthday','Address','ContactNumber','EmailAddress');
$this->grocery_crud->required_fields('FirstName','LastName','MiddleName','Birthday','Address');
$this->grocery_crud->set_field_upload('image','assets/uploads/files/Student');
$data = $this->selectCourseDesc();
$this->grocery_crud->field_type('CourseID','enum',$data);
 
 
if($operation =='insert_validation' || $operation == 'insert')
{
$this->grocery_crud->set_rules('StudentNumber','Student Number','numeric|xss_clean|trim|required|callback_studentNumber_check|is_unique[tblstudent.StudentNumber]');
$this->grocery_crud->set_rules('ContactNumber','Contact Number','numeric|xss_clean|trim|required');
$this->grocery_crud->set_rules('EmailAddress','Email Address','xss_clean|callback_validEmailAdd');
$this->grocery_crud->callback_insert(array($this,'findcourseID'));
 
}
else
{
$this->grocery_crud->set_rules('StudentNumber','StudentNumber','numeric|xss_clean|trim|required|callback_Student_number_checking');
$this->grocery_crud->set_rules('ContactNumber','Contact Number','numeric|xss_clean|trim|required');
$this->grocery_crud->set_rules('EmailAddress','Email Address','xss_clean|callback_validEmailAdd|callback_Student_email_checking');
$this->grocery_crud->callback_update(array($this,'updatefindcourseID'));
}
 
$output = $this->grocery_crud->render();
 
        $this->_Student_output($output);     
}

 

 

 

 

public function findcourseID($post_array)
{
$post_array['CourseID']=$this->db->where('CourseDesc',$post_array['CourseID'])->get('tblcourse')->row()->CourseID;
$this->db->insert('tblstudent',$post_array);
return TRUE;
}

davidoster
  • profile picture
  • Member

Posted 31 July 2013 - 06:31 AM

Hello and welcome to the forums [member=revshare lanuza].

What is the structure of the table?

Is the table's date format compatible with the date format that is declared within application/config/grocery_crud.php on line:

 
//There are only three choices: "uk-date" (dd/mm/yyyy), "us-date" (mm/dd/yyyy) or "sql-date" (yyyy-mm-dd) 
$config['grocery_crud_date_format'] = 'uk-date';

If you put the birthday date as required does it let you save? If not then the entered date is not correct.

 

 

Also try to do this instead, 

// replace this
$this->db->insert('tblstudent',$post_array);
return TRUE;

// with this
return $this->db->insert('tblstudent',$post_array);

I am not sure if this is going to make any changes but it's worth trying.


Revshare Lanuza
  • profile picture
  • Member

Posted 31 July 2013 - 11:45 AM

i used the default date of Grocery crud.

the Datepicker one,

 

 

i try this but it didnt work

 

return $this->db->insert('tblstudent',$post_array);

 

 

the date is not inserting into my database  ,

but if i remove the callback_insert  

the date is working. 

i dont know what is the problem with this callback?_insert


davidoster
  • profile picture
  • Member

Posted 31 July 2013 - 12:13 PM

Which version of CodeIgniter and Grocery CRUD do you use?


Amit Shah
  • profile picture
  • Member

Posted 02 August 2013 - 06:18 AM

make a dump of the array you trying to insert ... check what are the exact values you getting. If the value you trying to insert .. is not in the proper format, it can create trouble inserting. share the dump of the post_array before making call to insert.. may be it can be of some help.