根据Grocery CRUD中的第三个参数设置下拉输入默认值 [英] Set dropdown input default value based on third parameter in Grocery CRUD

查看:240
本文介绍了根据Grocery CRUD中的第三个参数设置下拉输入默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码示例,

function product($parameter){

   $crud = new grocery_CRUD();
   ...
   $crud->callback_add_field('dropdown_field_name',array($this,'_add_field_callback'));
   ...
   $output = $crud->render();
}

我可以这样做吗?

function _add_field_callback($parameter){
   //load db model
   //call the result and return as dropdown input field with selected selection when value = $parameter 
}


推荐答案

实际上,使用控制器很容易做到这一点。例如,您可以直接执行:

Actually this is easy to do it by using the controller. For example you can simply do:

function product($parameter){

    $this->my_test_parameter = $parameter;

   $crud = new grocery_CRUD();
   ...
   $crud->callback_add_field('dropdown_field_name',array($this,'_add_field_callback'));
   ...
   $output = $crud->render();
}

和回调:

function _add_field_callback($parameter){
   //load db model
   //call the result and return as dropdown input field with selected selection when value = $parameter 

   $value = !empty($this->my_test_parameter) ? $this->my_test_parameter : '';
   ...
   //here you can also use the form_dropdown of codeigniter (http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html)
}   

我知道你迫切期待杂货CRUD的默认值,所以我向github添加了一个问题 https://github.com/scoumbourdis/grocery-crud/issues/138 。这将是一个提醒,这件事必须得到解决。

I know that you are desperately looking forward for the default value for grocery CRUD so I added an issue to the github https://github.com/scoumbourdis/grocery-crud/issues/138 . This is will be a reminder that this thing has to be fixed.

这篇关于根据Grocery CRUD中的第三个参数设置下拉输入默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆