[英]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 数据库关系”
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.