Skip to content

Miscellaneous

selectTag()

selectTag() — returns any

Builds and returns a string containing a select form control based on the supplied name and options. Note: Pass any additional arguments like class, rel, and id, and the generated tag will also include those values as HTML attributes.

NameTypeRequiredDefaultDescription
namestringyes—See documentation for textFieldTag.
optionsanyyes—See documentation for select.
selectedstringyes—Value of option that should be selected by default.
includeBlankanyyesfalseSee documentation for select.
multiplebooleanyesfalseWhether to allow multiple selection of options in the select form control.
valueFieldstringyes—See documentation for select.
textFieldstringyes—See documentation for select.
labelstringyes—See documentation for textField.
labelPlacementstringyesaroundSee documentation for textField.
prependstringyes—See documentation for textField.
appendstringyes—See documentation for textField.
prependToLabelstringyes—See documentation for textField.
appendToLabelstringyes—See documentation for textField.
<!--- Controller code --->
<cfset cities = model("city").findAll()>

<!--- View code --->
<cfoutput>
    #selectTag(name="cityId", options=cities)#
</cfoutput>

<!--- Do this when CFWheels isn''t grabbing the correct values for the `option`s'' values and display texts --->
<cfoutput>
	#selectTag(name="cityId", options=cities, valueField="id", textField="name")#
</cfoutput>