Reputation: 647
I just code with GroceryCRUD, This is my Database:
a_guest_data
guest_no
register_date
name
gender
birthday
address
city
country
phone
email
ref
status
date_modified
a_table_data
id_table
tbl_name
group_name
status
seat
party_date
locked
pos_tbl
date_modified
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).
How can I do that?
Upvotes: 3
Views: 3388
Reputation: 87
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"
Documentation for about database relationships
What you want to achieve in grocery crud terms is set_relation.
Syntax for set_relation
:
void set_relation( string $field_name , string $related_table, string $related_title_field [, mixed $where [, string $order_by ] ] )
In the end your priority
field will also be in the table a_guest_data
Upvotes: 1
Reputation: 171
You are using a multiple select input, try removing MULTIPLE markup. It depends on what type of select you are using.
Upvotes: 0