-
parent Filter?
i have three tables
1.product details
2.brand
3.categories
because each manufacturer have different categories, i create the the categories table with 'brand' and 'category' field:
brand A - category 1a
brand A - category 2a
brand B - category 1b
brand B - category 2b
in the backend, when edit product detail, i'd like the category field (select field type) to show only value according to what the brand field (also select field type) selected. So when i select 'Brand A' it will only shows 'category 1a' and 'category 2a'. Is it possible to do this without using the Taxonomy module? Is this what the parent Filter for?
Thanks for the help
-
Re: parent Filter?
You can provide an options_callback for the category field
the callback should looks like this:
Code:
public function listCategory(DataContainer $objDc) {
$brand = $objDc->activeRecord->brand; // assuming your brand field is named brand
// the following depends on how you named your fields :)
$res = $this->Database->prepare('SELECT id,name FROM category WHERE brand=?')->execute($brand);
$k = $res->fetchEach('id');
$v = $res->fetchEach('name');
if (is_array($k) && is_array($v)) {
return array_combine($k, $v);
}
return array(''=>'no category for the brand');
}