下面的代码示例,
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
}
实际上,使用控制器很容易做到这一点。例如,您可以简单地执行以下操作:
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 https://github.com/scoumbourdis/grocery-crud/issues/138。这将提醒您必须解决这个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)