Hi,
I am using this library to make something like category and subcategory. But I am not getting proper value in select boxes of category and sub category. Below is my code, can anyone please check my code and tell me, where I am doing wrong.
In my example the themes are as category and subthemes are as subcategory.
// THEME & SUBTHEME
function check_theme ()
{
$crud = new grocery_CRUD();
$crud->set_table('articles');
$crud->set_relation('article_theme_id', 'themes', 'theme_name');
$crud->set_relation('article_subtheme_id', 'sub_themes', 'subtheme_name');
$crud->unset_add_fields('article_content');
$this->load->library('gc_dependent_select');
// settings
$fields = array(
// first field:
'Themes' => array( // first dropdown name
'table_name' => 'themes', // table of country
'title' => 'theme_name', // country title
'relate' => null // the first dropdown hasn't a relation
),
// second field
'SubThemes' => array( // second dropdown name
'table_name' => 'sub_themes', // table of state
'title' => 'subtheme_name', // state title
'id_field' => 'subtheme_id', // table of state: primary key
'relate' => 'theme_ids', // table of state:
'data-placeholder' => 'select subthem' //dropdown's data-placeholder:
),
);
$config = array(
'main_table' => 'articles',
'main_table_primary' => 'article_id',
"url" => base_url().'index.php/'.__CLASS__.'/'.__FUNCTION__.'/', //path to method
'ajax_loader' => base_url().'img/ajax-loaders/ajax-loader-2.gif', // path to ajax-loader image. It's an optional parameter
'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);
}
Here is the screenshots of my above code. By default its showing all records of themes and subthemes. But I want only those subtheme which theme selected from the theme dropdown.


Thanks for your help.! :)
