I have two tables categories
and subcategories
where categories
hasMany subcategories
relation.
I have another table products
which is related to categories
and subcategories
.
In add
method of products
I want to select category from the list and then subcategory associated with particular category selected.
echo $this->Form->input('category_id', ['options' => $categories, 'empty' => true]);
echo $this->Form->input('subcategory_id', ['options' => $subcategories]);
echo $this->Form->input('product_type_id', ['options' => $productTypes]);
echo $this->Form->input('title');
As there is no js
helper in CakePHP 3
. How could I do this using Ajax.
I'm new to CakePHP and Ajax as well. And currently this show all subcategories
in the list.