I have this code for my products
function products_v()
{
try{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('products');
$crud->set_subject('Products');
$crud->required_fields(
'id',
'name',
'category',
'subcategory'
);
$crud->columns(
'id',
'name',
'category',
'subcategory'
'price',
'active',
'image'
);
$crud->set_relation('id_category', 'category', 'name_category');
$crud->set_relation('id_subcategory', 'subcategory', 'name_subcategory');
$crud->set_field_upload('image','images/products');
$output = $crud->render();
$this->load->view('products_v', $output);
}
It's working ok, but I would like to know how can I do when I choose a category, the other select (subcategory) just show subcategories from the same category.
Ex.
Category: Wine
Subcategory:
- Red
- White
- Rosé
Hope can help me, thanks in advance!