select() with grouped output/optgroup

48 views
Skip to first unread message

funaroma

unread,
Mar 22, 2016, 4:46:59 PM3/22/16
to CFWheels
I need a CFW select() but I need the options to be able to be grouped so that I can have states fall under a "country" optgroup.  It still needs to be a select so I can do validations with my object.  Do i have any way to feed the options in other than a straight recordset?

Andrew Bellenie

unread,
Mar 22, 2016, 9:15:52 PM3/22/16
to ColdFusion on Wheels
You don't need to use select() to do validations. Just ensure a <select> tag is named appropriately, using modelname[property] format, e.g.

<select name="post[author]">
<option...


On 23 March 2016 at 04:46, funaroma <advan...@gmail.com> wrote:
I need a CFW select() but I need the options to be able to be grouped so that I can have states fall under a "country" optgroup.  It still needs to be a select so I can do validations with my object.  Do i have any way to feed the options in other than a straight recordset?

--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.
To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

funaroma

unread,
Mar 23, 2016, 8:01:04 AM3/23/16
to CFWheels
meh.  time for a plugin.

Per Djurner

unread,
Mar 23, 2016, 8:08:07 AM3/23/16
to CFWheels
Let me know if you get that working because it sounds like something we'd eventually like to add to the framework itself.

funaroma

unread,
Mar 23, 2016, 8:31:19 AM3/23/16
to CFWheels
Will do.  I'd prefer being able to base it off the existing code for select() and selectTag() - advice on how i might do that?

Per Djurner

unread,
Mar 23, 2016, 8:40:32 AM3/23/16
to CFWheels
Not sure but perhaps it's easier to just build it into core straight away and not do a plugin?
If so, you can send a pull request when done :)

Chris Peters

unread,
Mar 23, 2016, 9:10:23 AM3/23/16
to cfwh...@googlegroups.com
Any ideas on what the arguments syntax should look like? Should it have some sort of group argument that would work a little bit like how includePartial works?

Chris Peters
Web Developer
Liquifusion Studios

chris....@liquifusion.com
Skype: liquifusion.support
www.liquifusion.com

Per Djurner

unread,
Mar 23, 2016, 9:38:40 AM3/23/16
to cfwh...@googlegroups.com
How about something like this (groupField being the new functionality)?

q = model("state").findAll(include="country") // assumes we get name and countryName back
#select(objectName="x", property="x", options=q, textField="name", groupField="countryName")#

Chris Peters

unread,
Mar 23, 2016, 9:43:23 AM3/23/16
to cfwh...@googlegroups.com
I like it. 👍

Thorsten Eilers

unread,
Mar 23, 2016, 11:04:25 AM3/23/16
to CFWheels
The tag cfoutput has the group argument. Maybe it should be named accordingly? But i like the idea.

Chris Peters

unread,
Mar 23, 2016, 11:10:33 AM3/23/16
to cfwh...@googlegroups.com
I think the idea of groupField is to name it similarly to other arguments in select/selectTag: valueField and textField. Make sense?

On Wed, Mar 23, 2016 at 11:04 AM, 'Thorsten Eilers' via CFWheels <cfwh...@googlegroups.com> wrote:
The tag cfoutput has the group argument. Maybe it should be named accordingly? But i like the idea.
--
You received this message because you are subscribed to the Google Groups "CFWheels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cfwheels+u...@googlegroups.com.
To post to this group, send email to cfwh...@googlegroups.com.
Visit this group at https://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.

Thorsten Eilers

unread,
Mar 23, 2016, 3:09:08 PM3/23/16
to CFWheels
Also a viable option.

funaroma

unread,
Mar 24, 2016, 8:57:12 AM3/24/16
to CFWheels
groupField could be a list, if you want to get existentially hierarchical
Reply all
Reply to author
Forward
0 new messages