⚠ 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

How can I duplicate a row using add_action ?



XemmeX
  • profile picture
  • Member

Posted 05 October 2015 - 14:40 PM

Hi everyone!

We have create a MySQL stored procedure that can be called this way :

function duplicate_row($primary_key, $row){
$this->db->where('id',$primary_key);
$selected_id = $this->db->get('icml_product')->row();
$sp = 'call sp_duplicate_product('.$selected_id.', 0, @output);';
$out = "select @output;";
$this->db->query($sp)->row();
if($this->db->query($out) == '0'){
return 0;
}else{
return -1;
}
}

We add this add_action to our controller :

$crud->add_action('Duplicate', '', '', 'fa-copy', array($this,'duplicate_row'));

But the result in the list view is : 

2015_10_05_10_34_13.png

And finaly, the worst is that it create, on load, a copy of the 10 rows without any click on the Duplicate btn! :(

Any idea... I'm a bit lost here!