View Helpers
authenticityTokenField()
Signature
Section titled “Signature”authenticityTokenField() — returns string
Available in: controller
Category: General Form Functions
Description
Section titled “Description”Returns a hidden form field containing a new authenticity token.
Examples
Section titled “Examples”// 1. Include CSRF token in a plain HTML form that POSTs data
// (use this when you are not using startFormTag())
<form action="#urlFor(route='posts')#" method="post">
#authenticityTokenField()#
<!--- other fields here --->
</form>
// 2. Not needed for GET forms — GET requests are not CSRF-protected
<form action="#urlFor(route='posts')#" method="get">
<!--- no token required --->
</form>