Skip to content

View Helpers

startFormTag()

startFormTag() — returns string

Available in: controller Category: General Form Functions

Builds and returns a string containing the opening form tag. The form’s action will be built according to the same rules as URLFor. Note: Pass any additional arguments like class, rel, and id, and the generated tag will also include those values as HTML attributes.

NameTypeRequiredDefaultDescription
methodstringnopostThe type of method to use in the form tag (delete, get, patch, post, and put are the options).
multipartbooleannofalseSet to true if the form should be able to upload files.
routestringnoName of a route that you have configured in config/routes.cfm.
controllerstringnoName of the controller to include in the URL.
actionstringnoName of the action to include in the URL.
keyanynoKey(s) to include in the URL.
paramsstringnoAny 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.
anchorstringnoSets an anchor name to be appended to the path.
onlyPathbooleannotrueIf true, returns only the relative URL (no protocol, host name or port).
hoststringnoSet this to override the current host.
protocolstringnoSet this to override the current protocol.
portnumericno0Set this to override the current port number.
prependstringnoString to prepend to the form control. Useful to wrap the form control with HTML tags.
appendstringnoString to append to the form control. Useful to wrap the form control with HTML tags.
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.
<!--- View Code --->
#startFormTag(action="create")#
    <!--- your form controls --->
#endFormTag()#