简体   繁体   English

GroceryCRUD:如何设置字段下拉列表

[英]GroceryCRUD : How to set field dropdown

I just code with GroceryCRUD, This is my Database:我只是用 GroceryCRUD 编码,这是我的数据库:

a_guest_data a_guest_data

guest_no
register_date 
name 
gender 
birthday 
address 
city 
country 
phone 
email 
ref 
status 
date_modified

a_table_data a_table_data

id_table 
tbl_name 
group_name 
status 
seat 
party_date 
locked 
pos_tbl 
date_modified

a_table_group a_table_group

id_table 
guest_no 
priority

This is my Code for the Controller:这是我的控制器代码:

public function guest_management()
{
    $crud = new grocery_CRUD();

    $crud->set_table('a_guest_data');
    $crud->set_subject('Guest');
    $crud->set_relation_n_n('tables', 'a_table_group', 'a_table_data', 'guest_no', 'id_table', 'tbl_name');
    $crud->unset_columns('register_date','layout_no', 'date_modified', 'ref');

    $crud->fields('name', 'register_date', 'gender', 'birthday', 'tables', 'address', 'city', 'country', 'phone', 'email', 'ref', 'status' );


    $crud->field_type('country','dropdown', array('Indonesia' => 'Indonesia', 'Others' => 'Others'));
    $crud->field_type('gender','dropdown', array('Male' => 'Male', 'Female' => 'Female'));
    $crud->field_type('status','dropdown', array('1' => '1', '2' => '2'));

    $output = $crud->render();

    $this->_example_output($output);
}

And I have the form like this我有这样的表格在此处输入图片说明在此处输入图片说明

In the field Tables, I want to set the dropdown fields that only can choose 1 table (The Fact is, now in the field Tables, I can choose many options table. *See in the picture, I choose Table 1, 45, 6, 34).在字段Tables中,我想设置只能选择1个表的下拉字段(事实是,现在在字段Tables中,我可以选择多个选项表。*如图所示,我选择了Table 1, 45, 6 , 34)。

How can I do that?我怎样才能做到这一点?

This behavior is due to your database structure.此行为是由于您的数据库结构造成的。 If you only want one table value you need your database structure to be " 1-n database relation "如果你只想要一个表值,你需要你的数据库结构是“ 1-n 数据库关系

1-n 数据库关系

Documentation for about database relationships 关于数据库关系的文档

What you want to achieve in grocery crud terms is set_relation.在杂货杂货术语中,您想要实现的是 set_relation。

Syntax for set_relation : set_relation语法:

void set_relation( string $field_name , string  $related_table, string $related_title_field  [, mixed $where [, string $order_by ] ] )

Docs for set_relation set_relation 的文档

In the end your priority field will also be in the table a_guest_data最后,您的priority字段也将出现在表a_guest_data

You are using a multiple select input, try removing MULTIPLE markup.您正在使用多选输入,请尝试删除 MULTIPLE 标记。 It depends on what type of select you are using.这取决于您使用的选择类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Codeigniter 在 GroceryCRUD 上设置关系 - Set relations on GroceryCRUD with Codeigniter GroceryCRUD-如何在回调中设置变量? (我上传了一个文件,想要将其调整大小3倍,然后将所有3个放入数据库-我该如何保存该数据)? - GroceryCRUD - how to set variables in a callback? (I upload a file, want to resize it 3 times and put all 3 in the db - how do i save that data)? 如何在杂货店中使CRUD一对多? - How make CRUD of one to many in grocerycrud? 选择下拉列表时如何在其他文本字段中设置值? - How to set value in the other text field when dropdown list selected? CodeIgniter / GroceryCrud:单选按钮/下拉依赖于取消隐藏隐藏字段 - CodeIgniter / GroceryCrud : radio button / drop down dependent to unhide hidden field GroceryCrud 使用 where 子句设置 nn 关系 - GroceryCrud set a n-n relation with where clause CodeIgniter GroceryCrud set_relation在多个表中具有相同的ID - CodeIgniter GroceryCrud set_relation same id in multiple tables GroceryCrud表关系set_model(联接表)[编辑] - GroceryCrud Table Relationships set_model (join tables) [EDITED] 如何在groceryCrud中使用回调函数作为视图记录页面? - How can I use callback functions in groceryCrud for the view record page? 如何在GroceryCrud中的创建表单中添加一些自定义注释 - How to add some custom annotations in a create Form in GroceryCrud
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM