Thanks for the suggestion, but I'm not sure if structs can help me.
From what I understand, with the struct, I can only pass the key value
and the option's text field, right? What I'm looking for is a way to
populate the option's value and text fields, and then store additional
information in custom attributes.
For example, let's say I had a database table with three columns, I
want column 1 to be the value, column 2 to be the text for the option,
and I want to store column 3 as an attribute that I can access later
with JavaScript.
It doesn't need to be in a custom attribute, but I'm not very familiar
with structs, so I can't figure out how I could use it to pass all
three values to an option without combining two values into a
delimited string and separating it later when I want to use it.
What I have now is something like this:
#selectTag(name="name", options=foo, valueField="column1",
textField="column2", data_info=foo.column3)#
Which doesn't work because it only applies the data_info attribute to
the select tag, not the options.
Also, I apologize if my original question was too vague to know what I
was looking for.
Any ideas? Thanks
On Dec 8, 1:13 pm, Mohamad El-Husseini <husseini....@gmail.com> wrote:
> Do you have to use custom data tags? If not, you pass the selectTag() a
> list of options in key value pairs (using a struct):
>
> #selectTag(name="name", options={ 1 = "Option one", 2 = "Option 2" })#
>
> You can also set this struct up in your controller if you prefer and pass
> it as a variable. This will result in the following HTML:
>
> <option value="1">Option one</option>
>
> It's not a custom data attribute, but it does allow you to pass extra data.
> The struct key can be a string. It doesn't have to be numeric.
--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.
Okay, so I'm using the CfWheels "selectTag()" function to generate a
list, and what I want to do is store a little more information using
custom attributes on each of the options.
Here's what I've tried:
#selectTag(name="name", options=foo, data_info=foo.bar)#
This adds the attribute "data_info" to the select tag. I want to add
the data to each of the options instead. Is there a way to do this?
I want similar to this:
<select>
<cfloop query="foo">
<cfoutput><option data-short="#foo.bar#">Text</option></cfoutput>
</cfloop>
</select>
Any help?
Thanks in advance,
-Zach L
From what I understand, with the struct, I can only pass the key value
and the option's text field, right? What I'm looking for is a way to
populate the option's value and text fields, and then store additional
information in custom attributes.
For example, let's say I had a database table with three columns, I
want column 1 to be the value, column 2 to be the text for the option,
and I want to store column 3 as an attribute that I can access later
with JavaScript.
It doesn't need to be in a custom attribute, but I'm not very familiar
with structs, so I can't figure out how I could use it to pass all
three values to an option without combining two values into a
delimited string and separating it later when I want to use it.
What I have now is something like this:
#selectTag(name="name", options=foo, valueField="column1",
textField="column2", data_info=foo.column3)#
Which doesn't work because it only applies the data_info attribute to
the select tag, not the options.
Also, I apologize if my original question was too vague to know what I
was looking for.
Any ideas? Thanks
On Dec 8, 1:13 pm, Mohamad El-Husseini <husseini....@gmail.com> wrote:
Thanks for your suggestions! I decided to throw together a partial for
now. If I find that I reuse the code a lot I'll probably end up making
a more modular helper function like you suggested.
Thanks again to everybody for your suggestions.
> >http://groups.google.com/group/cfwheels?hl=en.- Hide quoted text -
>
> - Show quoted text -
#select(
objectName="product", property="countryId",
label="Country of Manufacture",
includeBlank="Select Country",
options=model("country").findAll(order="iseea DESC, name ASC"), valueField='id', textField='name'
)#
--
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 http://groups.google.com/group/cfwheels.
For more options, visit https://groups.google.com/d/optout.