SebTags 1.0 Documentation: Multi-Value Fields

Multi-Value Fields

Some field types accept multiple possible values from which a user can choose. Each of these works on the same principles.

The values for each of these fields will be sent and received as a comma-delimited list regardless of how the data is retrieved (below). The value will be correctly compared to the options regardless of how the option data is retrieved.

Options

The "options" type is special in that it acts like a different type depending on the number of options available:

Each of these types allows multiple methods for getting the data

Lists (subvalues)

The "subvalues" attribute will take a (comma delimited) list of possible values.

<cf_sebField type="radio" name="color" subvalues="red,blue,green">

Optionally, labels for these values can be provided by the "subdisplays" attribute (both must have the same number of items).

<cf_sebField type="radio" name="color" subvalues="red,blue,green" subdisplays="Red,Blue,Green">

Nested Tags (cf_sebSubField)

The cf_sebField tag can use data from nested cf_sebSubField tags:

<cf_sebField type="radio" name="color">
	<cf_sebSubField value="red" display="Red">
	<cf_sebSubField value="blue" display="Blue">
	<cf_sebSubField value="green" display="Green">
</cf_sebField>

Query (subquery)

A query can be used to provide data for cf_sebField. The "subquery" attribute will indicate the name of the query. In which case the "subvalues" (required) attribute will indicate which column in the query to use for the value. If provided, the "subdisplays" attribute will indicate the column used for display (if not provided, the subvalues column will be used for both).

<cf_sebField type="radio" name="color" subquery="qColors" subvalues="colorname">

Array (subarray)

An array of structures can be used to provide data. In which case, the "subvalues" attribute will indicate the key holding the value and (if provided) the "subdisplays" attribute will indicate the key for the display.

<cfset variables.options = [
	{value="1", display="One"},
	{value="2", display="Two"},
	{value="3", display="Three"}
]>
<cf_sebField type="select" subarray="#variables.options#" subvalues="value" subdisplays="display">

(from Joseph Lamoree)

CFC (CFC_Component)

A CFC method that gets a query from a CFC method can be used just list a query.

<cf_sebField type="radio" name="color" CFC_Component="#Application.Colors#" CFC_Method="getColors" subvalues="colorname">

If arguments are needed, the CFC_GetArgs attribute can be used.

<cf_sebField type="radio" name="color" CFC_Component="#Application.Colors#" CFC_Method="getColors" CFC_GetArgs="#sMyColors#" subvalues="colorname">

CFC (subcomp)

The "subcomp" attribute (a string) can be used to set a default value for the "CFC_Component" attribute (above). If the "subcomp" attribute exists, then cf_sebField will look at the CFC_Component for the parent cf_sebForm tag (if one exists).

First it will look for a component matching the attribute value within the cf_sebForm CFC_Component. For example if the cf_sebForm "CFC_Component" value was "#Application.Employees#", it would look for Application.Employees[attributes.subcomp]. If that existed and was a component, then the "CFC_Component" attribute of the cf_sebField tag would use that component.

Next it would look for a method in the cf_sebForm CFC_Component named "getParentComponent". If that method exists and returned a component, then it would run the same logic as above on the returned component.

Titles (subtitles)

The "subtitles" attribute can be used in all of the above examples just like the "subdisplays" attribute, except that it will set the "title" attribute for each choice.

Top Option (for select)

For type="select", you can use the "topopt" and "topoptvalue" attributes to set the display and value for the first select option (which always appears before any options with data). Both default to an empty string. Note that if "topoptvalue" is not an empty string, then cf_sebForm will consider the form to have a value and will not trigger a required validation if no other option is chosen.