Skip to content

View Helpers

submitTag()

submitTag() — returns string

Available in: controller Category: General Form Functions

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.

NameTypeRequiredDefaultDescription
valuestringnoSave changesMessage to display in the button form control.
imagestringno—File name of the image file to use in the button form control.
prependstringno—String to prepend to the form control. Useful to wrap the form control with HTML tags.
appendstringno—String to append to the form control. Useful to wrap the form control with HTML tags.
encodeanynotrueUse 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.
// 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>