Skip to content

View Helpers

buttonTo()

buttonTo() — returns string

Available in: controller Category: Link Functions

Creates a form containing a single button that submits to the URL. The URL is built the same way as the linkTo function.

NameTypeRequiredDefaultDescription
textstringno—The text content of the button.
imagestringno—If you want to use an image for the button pass in the link to it here (relative from the images folder).
routestringno—Name of a route that you have configured in config/routes.cfm.
controllerstringno—Name of the controller to include in the URL.
actionstringno—Name of the action to include in the URL.
keyanyno—Key(s) to include in the URL.
paramsstringno—Any additional parameters to be set in the query string (example: wheels=cool&x=y). Please note that CFWheels uses the & and = characters to split the parameters and encode them properly for you. However, if you need to pass in & or = as part of the value, then you need to encode them (and only them), example: a=cats%26dogs%3Dtrouble!&b=1.
anchorstringno—Sets an anchor name to be appended to the path.
onlyPathbooleannotrueIf true, returns only the relative URL (no protocol, host name or port).
hoststringno—Set this to override the current host.
protocolstringno—Set this to override the current protocol.
portnumericno0Set this to override the current port number.
encodeanynotrueWhen set to true, encodes tag content, attribute values, and URLs so that Cross Site Scripting (XSS) attacks can be prevented. Set to attributes to only encode attribute values and not tag content.
#buttonTo(text="Delete Account", action="perFormDelete", disable="Wait...")#

<!--- apply attributes to the input element by prefixing any arguments with "input"--->
#buttonTo(text="Edit", action="edit", inputId="edit-button", inputClass="edit-button-class")#