Skip to content

Miscellaneous

radioButton()

radioButton() — returns any

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

NameTypeRequiredDefaultDescription
objectNameanyyesSee documentation for textField.
propertystringyesSee documentation for textField.
associationstringyesSee documentation for textfield.
positionstringyesSee documentation for textfield.
tagValuestringyesThe value of the radio button when selected.
labelstringyesuseDefaultLabelSee documentation for textField.
labelPlacementstringyesaroundSee documentation for textField.
prependstringyesSee documentation for textField.
appendstringyesSee documentation for textField.
prependToLabelstringyesSee documentation for textField.
appendToLabelstringyesSee documentation for textField.
errorElementstringyesspanSee documentation for textField.
errorClassstringyesfieldWithErrorsSee documentation for textField.
<!--- Basic example view code --->
<cfoutput>
	<fieldset>
		<legend>Gender</legend>
	    #radioButton(objectName="user", property="gender", tagValue="m", label="Male")#<br />
        #radioButton(objectName="user", property="gender", tagValue="f", label="Female")#
	</fieldset>
</cfoutput>

<!--- Shows radio buttons for selecting the genders for all committee members provided by the `members` association and nested properties --->
<cfoutput>
	<cfloop from="1" to="#ArrayLen(committee.members)#" index="i">
		<div>
			<h3>#committee.members[i].fullName#:</h3>
			<div>
				#radioButton(objectName="committee", association="members", position=i, property="gender", tagValue="m", label="Male")#<br />
				#radioButton(objectName="committee", association="members", position=i, property="gender", tagValue="f", label="Female")#
			</div>
		</div>
	</cfloop>
</cfoutput>