Set dropdown input default value based on third pa

2019-05-14 08:53发布

Code sample below,

function product($parameter){

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

Can I do something like this ?

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

2条回答
放荡不羁爱自由
2楼-- · 2019-05-14 09:12

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.

查看更多
手持菜刀,她持情操
3楼-- · 2019-05-14 09:20

I had implemented Grocery Crud in one of my web application.

Check this link on " How to create dependent dropdowns"

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

查看更多
登录 后发表回答