protected function make_crud() { $crud = parent::make_crud(); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: You can access this variables after calling parent's make_crud method: // $this->CRUD // $this->STATE // $this->STATE_INFO // $this->PK_VALUE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // set subject $crud->set_subject('Commodity'); // displayed columns on list, edit, and add, uncomment to use //$crud->columns('name'); //$crud->edit_fields('name', '_updated_by', '_updated_at'); //$crud->add_fields('name', '_created_by', '_created_at'); // caption of each columns $crud->display_as('name', 'Name'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // This function will automatically detect every methods in this controller and link it to corresponding column // if the name is match by convention. In other word, you don't need to manually define callback. // Here is the convention (replace COLUMN_NAME with your column's name) // // * callback column (called when viewing the data as list): // public function _callback_column_COLUMN_NAME($value, $row){} // // * callback field (called when show add and edit form): // public function _callback_field_COLUMN_NAME($value, $primary_key){} // // * validation rule callback (field validation when adding/editing data) // public function COLUMN_NAME_validation($value){} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $this->build_default_callback(); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put required field validation codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/required_fields) // eg: // $crud->required_fields( $field1, $field2, $field3, ... ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->required_fields('name'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put required field validation codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/unique_fields) // eg: // $crud->unique_fields( $field1, $field2, $field3, ... ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->unique_fields('name'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put field validation codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_rules) // eg: // $crud->set_rules( $field_name , $caption, $filter ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put set relation (lookup) codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_relation) // eg: // $crud->set_relation( $field_name , $related_table, $related_title_field , $where , $order_by ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put set relation_n_n (detail many to many) codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n) // eg: // $crud->set_relation_n_n( $field_name, $relation_table, $selection_table, $primary_key_alias_to_this_table, // $primary_key_alias_to_selection_table , $title_field_selection_table, $priority_field_relation ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put custom field type here // (documentation: http://www.grocerycrud.com/documentation/options_functions/field_type) // eg: // $crud->field_type( $field_name , $field_type, $value ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put Tabs (if needed) // usage: // $crud->set_outside_tab($how_many_field_outside_tab); // $crud->set_tabs(array( // 'First Tab Caption' => $how_many_field_on_first_tab, // 'Second Tab Caption' => $how_many_field_on_second_tab, // )); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Create custom search form (if needed) // usage: // $crud->unset_default_search(); // // Your custom form // $html = '<div class="row container col-md-12" style="margin-bottom:10px;">'; // $html .= '</div>'; // $html .= '<input name="keyword" placeholder="Keyword" value="'.$keyword.'" /> '; // $html .= '<input type="button" value="Search" class="crud_search btn btn-primary form-control" id="crud_search" />'; // $crud->set_search_form_components($html); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put callback here // (documentation: httm://www.grocerycrud.com/documentation/options_functions) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put custom error message here // (documentation: httm://www.grocerycrud.com/documentation/set_lang_string) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // $crud->set_lang_string('delete_error_message', 'Cannot delete the record'); // $crud->set_lang_string('update_error', 'Cannot edit the record' ); // $crud->set_lang_string('insert_error', 'Cannot add the record' ); $this->CRUD = $crud; return $crud; }
protected function make_crud() { $crud = parent::make_crud(); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: You can access this variables after calling parent's make_crud method: // $this->CRUD // $this->STATE // $this->STATE_INFO // $this->PK_VALUE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // set subject $crud->set_subject('City'); // displayed columns on list $crud->columns('country_id', 'name', 'tourism', 'commodity', 'citizen'); // displayed columns on edit operation $crud->edit_fields('country_id', 'name', 'tourism', 'commodity', 'citizen', '_updated_by', '_updated_at'); // displayed columns on add operation $crud->add_fields('country_id', 'name', 'tourism', 'commodity', 'citizen', '_created_by', '_created_at'); // caption of each columns $crud->display_as('country_id', 'Country'); $crud->display_as('name', 'Name'); $crud->display_as('tourism', 'Tourism'); $crud->display_as('commodity', 'Commodity'); $crud->display_as('citizen', 'Citizen'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put required field validation codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/required_fields) // eg: // $crud->required_fields( $field1, $field2, $field3, ... ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->required_fields('name'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put required field validation codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/unique_fields) // eg: // $crud->unique_fields( $field1, $field2, $field3, ... ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->unique_fields('name'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put field validation codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_rules) // eg: // $crud->set_rules( $field_name , $caption, $filter ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put set relation (lookup) codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_relation) // eg: // $crud->set_relation( $field_name , $related_table, $related_title_field , $where , $order_by ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->set_relation('country_id', $this->cms_complete_table_name('country'), 'name'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put set relation_n_n (detail many to many) codes here // (documentation: http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n) // eg: // $crud->set_relation_n_n( $field_name, $relation_table, $selection_table, $primary_key_alias_to_this_table, // $primary_key_alias_to_selection_table , $title_field_selection_table, $priority_field_relation ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->set_relation_n_n('tourism', $this->cms_complete_table_name('city_tourism'), $this->cms_complete_table_name('tourism'), 'city_id', 'tourism_id', 'name', NULL); $crud->set_relation_n_n('commodity', $this->cms_complete_table_name('city_commodity'), $this->cms_complete_table_name('commodity'), 'city_id', 'commodity_id', 'name', 'priority'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put custom field type here // (documentation: http://www.grocerycrud.com/documentation/options_functions/field_type) // eg: // $crud->field_type( $field_name , $field_type, $value ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->field_type('_created_at', 'hidden'); $crud->field_type('_created_by', 'hidden'); $crud->field_type('_updated_by', 'hidden'); $crud->field_type('_updated_at', 'hidden'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put Tabs (if needed) // usage: // $crud->set_outside_tab($how_many_field_outside_tab); // $crud->set_tabs(array( // 'First Tab Caption' => $how_many_field_on_first_tab, // 'Second Tab Caption' => $how_many_field_on_second_tab, // )); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put callback here // (documentation: httm://www.grocerycrud.com/documentation/options_functions) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $crud->callback_column('citizen', array($this, '_callback_column_citizen')); $crud->callback_field('citizen', array($this, '_callback_field_citizen')); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // HINT: Put custom error message here // (documentation: httm://www.grocerycrud.com/documentation/set_lang_string) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // $crud->set_lang_string('delete_error_message', 'Cannot delete the record'); // $crud->set_lang_string('update_error', 'Cannot edit the record' ); // $crud->set_lang_string('insert_error', 'Cannot add the record' ); $this->CRUD = $crud; return $crud; }