Can someone help me with getting the Dependent dropdown library working with the "Goods" test code as in
/topic/1087-updated-24112012-dependent-dropdown-library/.
I use Codeigniter 3 with HMVC from https://github.com/jlamim/ci3-hmvc, grocery-crud-1.5.4, Gc_dependent_select 1.5 and I have $config['index_page'] = 'index.php';
The drop down selection works only for Country but nothing happens when i click on state and city.
When I click on edit in a grocery crud http://.....hudev1/index.php/hem/goods/goods I get following error.
Error Number: 1054
Unknown column 'post_code' in 'where clause'
SELECT * FROM `dd_city` WHERE `state_ids` = '1' AND post_code>'167' ORDER BY `state_title` DESC
Filename: modules/grocery_crud/libraries/Gc_dependent_select.php
Line Number: 147
Similar problem was reported in
/topic/1087-updated-24112012-dependent-dropdown-library/page-6
response #120. I implemented proposed changes as in #121 but the problem remains.
Thanks in advance, Ingmar
My code and database is as follows:
public function goods() {
$crud = new grocery_CRUD();
$crud->set_table('dd_goods');
$crud->set_relation('goods_country', 'dd_country', 'country_title');
$crud->set_relation('goods_state', 'dd_state', 'state_title');
$crud->set_relation('goods_city', 'dd_city', 'city_title');
$this->load->library('gc_dependent_select');
// settings
$fields = array(
// first field:
'goods_country' => array(// first dropdown name
'table_name' => 'dd_country', // table of country
'title' => 'country_title', // country title
'relate' => null // the first dropdown hasn't a relation
),
// second field
'goods_state' => array(// second dropdown name
'table_name' => 'dd_state', // table of state
'title' => 'state_title', // state title
'id_field' => 'state_id', // table of state: primary key
'relate' => 'country_ids', // table of state:
'data-placeholder' => 'select state' //dropdown's data-placeholder:
),
// third field. same settings
'goods_city' => array(
'table_name' => 'dd_city',
'where' => "post_code>'167'", // string. It's an optional parameter.
'order_by' => "state_title DESC", // string. It's an optional parameter.
'title' => 'id: {city_id} / city : {city_title}', // now you can use this format )))
'id_field' => 'city_id',
'relate' => 'state_ids',
'data-placeholder' => 'select city'
)
);
$config = array(
'main_table' => 'dd_goods',
'main_table_primary' => 'goods_id',
'url' => base_url() . 'index.php/' . strtolower(__CLASS__) . '/' . strtolower(__FUNCTION__) . '/',
'ajax_loader' => base_url() . 'style/images/'. 'ajax-loader.gif',
'segment_name' => 'Your_segment_name' // It's an optional parameter. by default "get_items"
);
$categories = new gc_dependent_select($crud, $fields, $config);
// first method:
//$output = $categories->render();
// the second method:
$js = $categories->get_js();
$output = $crud->render();
$output->output.= $js;
$this->_example_output($output);
}
}
/*
CREATE TABLE IF NOT EXISTS `dd_country` (
`country_id` int(15) NOT NULL,
`country_title` varchar(255) DEFAULT NULL,
PRIMARY KEY (`country_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `dd_state` (
`state_id` int(15) NOT NULL,
`state_title` varchar(255) DEFAULT NULL,
`country_ids` int(15) NOT NULL,
PRIMARY KEY (`state_id`),
KEY `country_ids` (`country_ids`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `dd_city` (
`city_id` int(15) NOT NULL,
`city_title` varchar(255) DEFAULT NULL,
`state_ids` int(15) NOT NULL,
PRIMARY KEY (`city_id`),
KEY `state_ids` (`state_ids`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE IF NOT EXISTS `dd_goods` (
`goods_id` int(11) NOT NULL,
`goods_name` varchar(255) DEFAULT NULL,
`goods_country` int(11) NOT NULL,
`goods_state` int(11) NOT NULL,
`goods_city` int(11) NOT NULL,
PRIMARY KEY (`goods_id`),
KEY `goods_country` (`goods_country`),
KEY `goods_state` (`goods_state`),
KEY `goods_city` (`goods_city`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
*/