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 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

By Dave - July 1, 2015

Hi jsantari, 

Say you had a list field called "cities".  

  • In the field editor, for cities: set List Options to: Get options from MySQL Query
  • Enter a query something like this: SELECT num, cityName FROM `<?php echo $TABLE_PREFIX ?>city` WHERE state = '<?php echo $ESCAPED_FILTER_VALUE ?>'
  • Set "Advanced Filter: Refresh list when this field changes: " to "State"

Then when state gets updated some ajax will be fired for the city pulldown to update its contents by rerunning the mysql query with the new escaped filter value (which would be the newly selected state).

Note that when you select these options in the field editor there is some inline documentation on the page to help you.

Let me know how it goes!

Dave Edis - Senior Developer
interactivetools.com