Hi, I’ve reorganised the code in line with your suggestion, but it doesn’t work.
It doesn’t seem to matter what I put in:
$gantt->event->attach("beforeInsert", function_name);
it doesn’t do anything. Because I’m using CodeIgniter I’ve tried using $this->function_name and even placing the entire function in the $gantt->event->attach declaration, but it doesn’t do anything. The tasks database is updated, but the user_id field is not updated.
So the entire code I’m now trying (unsuccessully) is:
[code]
function my_insert($data){
$data->add_field(“user_id”,$this->session->userdata(‘user_id’));
}
public function data()
{
$gantt = new JSONGanttConnector($this->db, "phpCI");
$gantt->event->attach("beforeInsert", $this->my_insert);
$gantt->filter("user_id", $this->session->userdata('user_id'));
$gantt->render_links("gantt_links","id","source,target,type");
$gantt->render_table("gantt_tasks","id","start_date,duration,text,progress,parent,user_id");
}[/code]
I’ve tried all the following (individually) without success:
$gantt->event->attach("beforeInsert", $this->my_insert);
$gantt->event->attach("beforeInsert", "$this->my_insert"); // surround with quotes
$gantt->event->attach("beforeInsert", this->my_insert); // remove dollar sign
$gantt->event->attach("beforeInsert", my_insert); // after moving the my_insert function inside the data() function
$gantt->event->attach("beforeInsert", $data->add_field("user_id",$this->session->userdata('user_id')));
All these update the gant_tasks table without the user_id field.
Any suggestions?