Skip to content

View Helpers

endFormTag()

endFormTag() — returns string

Available in: controller Category: General Form Functions

Builds and returns a string containing the closing form tag. It’s typically used in conjunction with startFormTag().

NameTypeRequiredDefaultDescription
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.
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.
#startFormTag(action="create")#
 <input type="text" name="firstName" placeholder="First Name">
 <input type="text" name="lastName" placeholder="Last Name">
#endFormTag()#

Output:
<form action="/create" method="post">
 <input type="text" name="firstName" placeholder="First Name">
 <input type="text" name="lastName" placeholder="Last Name">
</form>

#startFormTag(action="update")#
 <input type="email" name="email" placeholder="Email">
#endFormTag(prepend="<div class='form-wrapper'>", append="</div>")#

Output:
<div class='form-wrapper'>
<form action="/update" method="post">
 <input type="email" name="email" placeholder="Email">
</form>
</div>

#startFormTag(action="login")#
 <input type="text" name="username">
#endFormTag(encode=true)#

Output:
<form action="/login" method="post">
 <input type="text" name="username">
</form>

#startFormTag(action="register", prepend="<section>")#
 <input type="text" name="username">
 <input type="password" name="password">
#endFormTag(append="</section>")#

Output:
<section>
<form action="/register" method="post">
 <input type="text" name="username">
 <input type="password" name="password">
</form>
</section>