简体   繁体   English

更改杂货杂货中的自定义按钮操作

[英]change custom button action in grocery crud

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: 我想传递用户应该被重定向的地址$which_url以及一个参数,但是它不起作用:

 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? 如何添加此功能?

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;
}

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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM