Jump to content

add_action triggers callback on init

add_action callback actions custom

  • Please log in to reply
1 reply to this topic

#1 Gianni Pinotto

Gianni Pinotto


  • Members
  • Pip
  • 1 posts

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.

#2 victor


    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 17 October 2012 - 09:45 AM

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

Also tagged with one or more of these keywords: add_action, callback, actions, custom

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users