Within my specific scenario, I have implemented a series of dropdown menus that are tiered depending on each other (specifically for Coldbox 3.5+ and CF9).
Utilizing bindCFC and cfajax, here is an example showcasing the first two dropdowns, with the second one being dependent on the first.
This snippet represents my view:
<cfform>
<cfselect name="groups" id="groups" bind="cfc:#getSetting('AppMapping')#.model.dynform.getGroups()"
bindOnLoad="Yes"
display="group_name"
value="group_id" />
<cfselect name="events" id="events" selected="#form.event_id#"
bind="cfc:#getSetting('AppMapping')#.model.dynform.getEventsByGroup({groups})"
display="event_name"
value="event_id"
queryPosition="below">
</cfform>
Below is a snippet from my model (dynform):
<cffunction name="getGroups" access="remote" output="false" returntype="query">
<cfset var qGroups = "">
<cfquery datasource="#application.DSN#" name="qGroups">
SELECT
egc.nd_event_group_id group_id,
egc.short_desc group_name
FROM event_group_code egc
WHERE egc.status_code = 'A'
ORDER BY egc.sort_order
</cfquery>
<cfreturn qGroups>
</cffunction>
<cffunction name="getEventsByGroup" access="remote" output="false" returntype="query">
<cfargument name="event_group_id" type="string" required="true">
<cfset var qEventsByGroup = "">
<cfquery datasource="#application.DSN#" name="qEventsByGroup">
SELECT ec.event_id,
ec.FULL_DESC as event_name
FROM events ec
WHERE ec.event_group_id = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.event_group_id#">
</cfquery>
<cfreturn qEventsByGroup>
</cffunction>
Although the method above functions correctly, I ultimately chose to adopt the jQuery/ajax JSON-based approach due to the following reasons:
In the Coldbox framework, handlers should handle the processing, not views directly
The use of CFajax/cfselect was slower compared to jQuery ajax, and offered fewer customization options. (For instance, what if I needed a multiple select box or additional data attributes returned?)
I preferred to avoid using the cfform tag in my view, which is a requirement for cfselect elements
If necessary, I can provide details on the jQuery ajax implementation, but I believe this response adequately addresses the initial inquiry.