Grocery CRUD - Multiple选择并向同一个表添加多行一次

时间:2018-04-11 07:07:08

标签: codeigniter grocery-crud multiple-select

enter image description here在我的项目中有一个依赖的下拉列表。我希望有时候从所有数据的下拉列表中选择多个数据,并且所有数据都将插入到同一个表中,而不是多对多个关系表。我的代码在--- ---

$this->load->library('grocery_CRUD');
$crud = new grocery_CRUD();

$crud->set_theme('flexigrid');
$crud->set_table('tbl_donation_ppl');
$crud->set_relation('fld_home_id', 'tbl_home_name', 'fld_name');
$crud->set_relation('fld_user_id','tbl_recipient', 'fld_name');
$crud->set_relation('fld_itemgrp_id', 'tbl_donate_group', 'fld_grp_name');

$crud->columns('fld_don_type', 'fld_home_id', 'fld_user_id', 'fld_itemgrp_id', 'fld_date', 'fld_details');
$crud->required_fields('fld_don_type','fld_home_id','fld_user_id', 'fld_itemgrp_id', 'fld_date');
$crud->display_as('fld_done_type', 'Donation Type');
$crud->display_as('fld_home_id', 'Home Name');
$crud->display_as('fld_user_id', 'Receipient');
$crud->display_as('fld_itemgrp_id', 'Donation Item');
$crud->display_as('fld_date', 'Donation Date');
$crud->display_as('fld_details', 'Details');

$crud->change_field_type('fld_don_type', 'dropdown', array('iftar' => 'ইফতার','jakat' => 'যাকাত','home' => 'ঘর'));
$crud->field_type('fld_user_id', 'multiselect');

$fields = array(
                //District Field
                'fld_home_id' => array(
                'table_name' => 'tbl_home_name',
                'title' => 'fld_name',
                'relate' => null
                ),
                'fld_user_id' => array(
                'table_name' => 'tbl_recipient',
                'title' => 'fld_name',
                'id_field' => 'fld_uid',
                'relate' => 'fld_home_id',
                'data-placeholder' => 'Select Home'
                ),
            );

            $config = array(
                'main_table' => 'tbl_home_name',
                'main_table_primary' => 'fld_uid',
                'url' => base_url() . 'index.php/libraries/makedonationppl/'
            );

$usrs = new gc_dependent_select($crud, $fields, $config);

$js = $usrs->get_js();
$output = $crud->render();

$output->output.=$js;

$this->__mycrud($output);

我想多选择“tbl_recipient”'并添加与所选项目一样多的行。但我可以一次只选择一个项目到tbl_donation_ppl表,有没有办法实现呢?提前谢谢。

1 个答案:

答案 0 :(得分:0)

您使用set_relation时应使用set_relation_n_n 这是链接https://www.grocerycrud.com/documentation/options_functions/set_relation_n_n

这样可以从下拉列表中选择多个值... 祝你好运!

相关问题