How to setup dependent list

4 posts by 2 authors in: Forums > CMS Builder
Last Post: July 1, 2015   (RSS)

By jsantari - June 30, 2015

I'm looking at cmsb for a new project and have a specific need for dependent lists. Each product will be assigned to a category from the categories table. Depending on the category assigned to a product I need the options for colors, size etc. to be pulled from the respective tables; color, sizes where I have defined values for color and sizes and assigned them values for each category. So what I need to understand is how to trigger a refresh of the color options when the user selects the category they are assigning the product too. Can't seem to understand from the docs how this should be setup.

By Dave - June 30, 2015

Hi jsantari, 

It depends if you're doing on the frontend or in the CMSB.  

I think what you're looking for are called "chained Selects".   You can create all the related tables in CMSB but CMSB doesn't have a code generator for chained selects.  You'll need to create them by hand with some custom code (php, mysql, ajax, jquery, etc).  Here's some links to get you started: https://www.google.com/search?q=chained+selects

I've also seen components on the web where you output all the data into the source of the page (assuming you don't have thousands of records) and a premade javascript component builds chains selects from that.  So that can be an easier method if you can find a component that does close to what you need.

That's all for the frontend, if you're doing it in CMSB there's some basic support.  In the field editor create a list field and set the "List Options" to "Get Options from MySQL query", and then you'll see some additional options appear (Advanced Filter: Refresh list when this field changes).  It easier, but still takes a bit of custom MySQL unfortunately, though.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By jsantari - July 1, 2015

Hi Dave,

Thanks for the response. I'm not worried about the front end, I can code that. Custom mysql is no problem. I guess what I need to know is how I access the trigger select value to pass to the custom mysql.

Example; if I had a states drop down and want the selected state to drive the options for the cities select.

Jim