I have 4 tables categories
, subcategories
, product_types
and products
. Each is associated with other in following hierarchy.
categories
|- subcategories
|- product_types
|- products
The view of add()
action of ProductsController
is
<?= $this->Form->create($product, ['type' => 'file', 'class' => 'ajax_page']) ?>
<fieldset>
<legend><?= __('Add Product') ?> <div class="ajax_loading_image"></div></legend>
<?php
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('product_code');
echo $this->Form->input('SKU');
echo $this->Form->input('title');
echo $this->Form->input('description');
</fieldset>
<?php echo $this->Form->end(); ?>
Right now it is list whole subcategories
in the list. I want to load subcategories
on change of categories
and product_types
on change of subcategories
using Ajax.
There is no good example I can found for CakePHP 3.x and also some documentation mentioned that js helper has been removed from CakePHP 3
How it can be implemented in CakePHP 3. I'm new to CakePHP and Ajax as well.
Thank You.