0

I have the code that adds two custom buttons into grocerycrud:

    try{
        $crud = new grocery_CRUD();
        $crud->set_table('my_table_1')->set_subject('something');
        $crud->add_action('food 1', 'http://taimapedia.org/images/e/e6/Nom_icon_64.png', '','ui-icon-image',array($this,'get_row_id' ));
        $crud->add_action('pillow', 'http://www.ademi.com/movilidad/Imagenes/ico_medica.png', '','ui-icon-image',array($this,'get_row_id'));
        $output = $crud->render();
        $this->_output_l($output);        
    }catch(Exception $e){
        show_error($e->getMessage().' --- '.$e->getTraceAsString());
    }

then a function to return primary key depending the row I am

function get_row_id($primary_key , $row)
{
    return site_url('person/other/').'?id_person='.$row->id_person;
}

I want to pass the address $which_url the user should be redirected as well as a parameter, but it did not work:

 function get_row_id($primary_key , $row, $which_url)
    {
        return site_url('person/'.$which_url.').'?id_person='.$row->id_person;
    }

how could I add this functionality?

edgarmtze
  • 24,683
  • 80
  • 235
  • 386

2 Answers2

0

I think it may be a typo?

Try:

function get_row_id($primary_key, $row, $which_url)
{
    return site_url('person/' . $which_url) . '?id_person=' . $row->id_person;
}
PaulK
  • 114
  • 1
  • 1
  • 6
  • what about calling it `array($this,'get_row_id','adress_one')` ? becasue I get: ` A PHP Error was encountered Severity: Warning Message: call_user_func(Array) [function.call-user-func]: First argument is expected to be a valid callback Filename: libraries/grocery_crud.php Line Number: 1611` – edgarmtze Mar 17 '13 at 19:02
0

I tried

$crud->add_action('action1', 'http://taimapedia.org/images/e/e6/Nom_icon_64.png', 'person/address_one');
$crud->add_action('action2', 'http://www.ademi.com/movilidad/Imagenes/ico_medica.png', 'person/address_two');
edgarmtze
  • 24,683
  • 80
  • 235
  • 386