3

下面的代码示例,

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

2 回答 2

4

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

And the callback:

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

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.

于 2012-12-11T23:41:25.543 回答
0

我在我的一个 Web 应用程序中实现了 Grocery Crud。

检查“如何创建依赖下拉菜单”上的此链接

http://demo.edynamics.co.za/grocery_crud/index.php/examples/customers_management/add

于 2012-12-11T13:07:36.887 回答