Second drop-down changes after select first drop down in Joomla XML

by Rakesh Singh   Last Updated September 12, 2017 09:10 AM

I am creating these drop down list in xml for plugin:- category multi-select dropdown, subcategory multi-select dropdown(all data come from database table) .i want when i select the first category drop down then the second drop down list come under the selected category on first drop down. Example:-

please me out how to achieve this.

Given below is table structure.

CREATE TABLE category ( cat_id int(2) NOT NULL auto_increment,

category

varchar(25) NOT NULL default ''

, PRIMARY KEY (cat_id) )

CREATE TABLE subcategory (subcat_id int(3) NOT NULL AUTO_INCREMENT,

cat_id int(2) NOT NULL DEFAULT '0',subcategory varchar(25) NOT NULL DEFAULT '', UNIQUE KEY subcat_id (subcat_id) )



Answers 1


Your sql_filter value must match the name of the field it is referring to. Since you have cat_id in your subcategory table which is referring to id in category, name your parent field as cat_id.

Your category field with name cat_id.

<field name="cat_id"
   type="sql"
   default=""
   label="Category"
   sql_select="e.*"
   sql_from="#__category AS e"
   sql_group="category"
   sql_order="e.cat_id ASC"
   key_field="cat_id"
   value_field="category"/>

Sub category field can be same as what you have now.

<field name="subcategory"
   default=""
   type="sql"
   label="SubCategory"
   sql_select="e.*"
   sql_from="#__subcategory AS e"
   sql_group="subcategory"
   sql_order="e.subcat_id ASC"
   sql_filter="cat_id"
   key_field="subcat_id"
   value_field="subcategory"/>
Nagarjun
Nagarjun
September 13, 2017 10:28 AM

Related Questions


How to remove rel="nofollow" with Joomla Buffer?

Updated May 28, 2017 04:10 AM

How to allow media manager open video files

Updated July 14, 2015 17:04 PM