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
namestringyesSee documentation for textFieldTag.
optionsanyyesSee documentation for select.
selectedstringyesValue of option that should be selected by default.
includeBlankanyyesfalseSee documentation for select.
multiplebooleanyesfalseWhether to allow multiple selection of options in the select form control.
valueFieldstringyesSee documentation for select.
textFieldstringyesSee documentation for select.
labelstringyesSee documentation for textField.
labelPlacementstringyesaroundSee documentation for textField.
prependstringyesSee documentation for textField.
appendstringyesSee documentation for textField.
prependToLabelstringyesSee documentation for textField.
appendToLabelstringyesSee 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>