Пример #1
0
 function addresses_management()
 {
     $this->load->library('grocery_CRUD');
     $this->load->library('ajax_grocery_CRUD');
     //create ajax_grocery_CRUD instead of grocery_CRUD. This extends the functionality with the set_relation_dependency method keeping all original functionality as well
     $crud = new ajax_grocery_CRUD();
     //this is the default grocery CRUD model declaration
     $crud->set_table('address');
     $crud->set_relation('ad_country_id', 'country', 'c_name');
     $crud->set_relation('ad_state_id', 'state', 's_name');
     //this is the specific line that specifies the relation.
     // 'ad_state_id' is the field (drop down) that depends on the field 'ad_country_id' (also drop down).
     // 's_country_id' is the foreign key field on the state table that specifies state's country
     $crud->set_relation_dependency('ad_state_id', 'ad_country_id', 's_country_id');
     $crud->unset_print();
     $crud->unset_export();
     //$crud->unset_add();
     // $crud->unset_edit();
     $crud->unset_delete();
     $output = $crud->render();
     $this->_example_output($output);
 }