View Helpers
submitTag()
Signature
Section titled “Signature”submitTag() — returns string
Available in: controller
Category: General Form Functions
Description
Section titled “Description”Builds and returns a string containing a submit button form control. Note: Pass any additional arguments like class, rel, and id, and the generated tag will also include those values as HTML attributes.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
value | string | no | Save changes | Message to display in the button form control. |
image | string | no | — | File name of the image file to use in the button form control. |
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. |
Examples
Section titled “Examples”// 1. Basic submit button inside a form
#startFormTag(action="save")#
<!--- form controls go here --->
#submitTag()#
#endFormTag()#
// -> <form action="/products/save" method="post">...<input type="submit" value="Save changes"></form>
// 2. Custom button label
#submitTag(value="Create Account")#
// -> <input type="submit" value="Create Account">
// 3. Image submit button
#submitTag(image="submit-button.png")#
// -> <input type="image" src="/images/submit-button.png">
// 4. Submit button with extra HTML attributes (class and id)
#submitTag(value="Place Order", class="btn btn-primary", id="order-submit")#
// -> <input type="submit" value="Place Order" class="btn btn-primary" id="order-submit">
// 5. Submit button wrapped with HTML using prepend and append
#submitTag(value="Save", prepend="<div class=""actions"">", append="</div>")#
// -> <div class="actions"><input type="submit" value="Save"></div>