⚠ 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

add_action triggers callback on init



Gianni Pinotto
  • profile picture
  • Member

Posted 16 October 2012 - 12:58 PM

Hi everyone, i need to add a custom action with relative callback. Here's a piece of the code of my controller:

function myFunction() {
..code before

// Setting custom actions.
$crud->add_action('Approva', '', '','ui-icon-image', array($this,'approve_submission'));

.. code after
}


function approve_submission($primary_key, $row) {

// Update authorization.
$data = array('auth' => 1);
$this->db->where('ID', $row->ID);
$this->db->update('segnalazioni', $data);
}

The problem is that all the code enclosed in the "approve_submission" function is executed at every controller load, and not when i click on the new action button (Approva).

It's like if the "add_action" method triggers its callback before any user click.
How could it be possible?

Thank you.

victor
  • profile picture
  • Member

Posted 17 October 2012 - 09:45 AM

HI! You have a problem because this function use to create a link!