Return to v2.5.0 docs

startFormTag()


View Helpers General Form Functions string controller


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.

Name Type Required Default Description
method string No post The type of method to use in the form tag (delete, get, patch, post, and put are the options).
multipart boolean No false Set to true if the form should be able to upload files.
route string No Name of a route that you have configured in config/routes.cfm.
controller string No Name of the controller to include in the URL.
action string No Name of the action to include in the URL.
key any No Key(s) to include in the URL.
params string No 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.
anchor string No Sets an anchor name to be appended to the path.
onlyPath boolean No true If true, returns only the relative URL (no protocol, host name or port).
host string No Set this to override the current host.
protocol string No Set this to override the current protocol.
port numeric No 0 Set this to override the current port number.
prepend string No String to prepend to the form control. Useful to wrap the form control with HTML tags.
append string No String to append to the form control. Useful to wrap the form control with HTML tags.
encode any No true Use this argument to decide whether the output of the function should be encoded in order to prevent Cross Site Scripting (XSS) attacks. Set it to true to encode all relevant output for the specific HTML element in question (e.g. tag content, attribute values, and URLs). For HTML elements that have both tag content and attribute values you can set this argument to attributes to only encode attribute values and not tag content.
<!--- View Code --->
#startFormTag(action="create")#
    <!--- your form controls --->
#endFormTag()#

Related Functions

General Form Functions