From b6ef10779e883b7428a1a99d4f58b0ae0528c3c3 Mon Sep 17 00:00:00 2001 From: Adam Jimerson Date: Tue, 20 Oct 2026 11:27:53 -0400 Subject: [PATCH 1/2] Update the Views section on the CSRF Middleware for `.csrf_field` Update the CSRF Middleware section of the Views page to document the usage of the introduced `.csrf_field` template function which returns a full HTML input field. Signed-off-by: Adam Jimerson --- en/the-basics/views.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/the-basics/views.md b/en/the-basics/views.md index 803b109f8..277279a1e 100644 --- a/en/the-basics/views.md +++ b/en/the-basics/views.md @@ -112,7 +112,7 @@ This middleware can be applied to routes to ensure that requests are coming from ::: v-pre 1. Register the middleware (`github.com/goravel/framework/http/middleware::VerifyCsrfToken(exceptPaths)`) to global or a specific route. -2. Add `` to your form in the view file, or add `X-CSRF-TOKEN={{ .csrf_token }}` to your request header to include the CSRF token. +2. Add `{{ .csrf_field }}` (which renders ``) to your form in the view file, or add `X-CSRF-TOKEN={{ .csrf_token }}` to your request header to include the CSRF token. 3. The middleware will automatically verify the token on form submission. ::: From b3be74eca25afefef0c3bf1216116ef4a303f275 Mon Sep 17 00:00:00 2001 From: Adam Jimerson Date: Fri, 23 Oct 2026 09:57:14 -0400 Subject: [PATCH 2/2] Update ZN docs Signed-off-by: Adam Jimerson --- zh_CN/the-basics/views.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh_CN/the-basics/views.md b/zh_CN/the-basics/views.md index 3e748ed47..aded3010e 100644 --- a/zh_CN/the-basics/views.md +++ b/zh_CN/the-basics/views.md @@ -113,7 +113,7 @@ func Boot() contractsfoundation.Application { ::: v-pre 1. 将中间件(`github.com/goravel/framework/http/middleware::VerifyCsrfToken(exceptPaths)`)注册到全局或特定路由。 -2. 在视图文件中向表单添加 ``,或在请求头中添加 `X-CSRF-TOKEN={{ .csrf_token }}` 以包含 CSRF 令牌。 +2. 在视图文件中向表单添加 `{{ .csrf_field }}`(会渲染为 ``),或在请求头中添加 `X-CSRF-TOKEN={{ .csrf_token }}` 以包含 CSRF 令牌。 3. 中间件将在表单提交时自动验证令牌。 :::