You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If :ref:`CSRF <cross-site-request-forgery>` filter is turned on ``form_open()`` will generate CSRF field at the beginning of the form. You can specify ID of this field by passing csrf_id as one of the ``$attribute`` array:
106
+
If :ref:`CSRF <cross-site-request-forgery>` filter is turned on ``form_open()`` will generate CSRF field at the beginning of the form. You can specify ID of this field by passing **csrf_id** as an element of the ``$attributes`` array:
.. note:: To use auto-generation of CSRF field, you need to turn CSRF filter on to the form page. In most cases it is requested using the ``GET`` method.
115
+
.. note:: To use auto-generation of CSRF field, you need to turn on the :ref:`CSRF filter <enable-csrf-protection>` in **app/Config/Filters.php** file.
116
+
In most cases the form page is requested using the GET method. Normally, CSRF protection is required
117
+
for POST/PUT/DELETE/PATCH requests, but even for GET requests, CSRF filters must be enabled for pages that display Forms.
118
+
119
+
If you enable CSRF filter with `$globals <https://codeigniter4.github.io/CodeIgniter4/incoming/filters.html#globals>`, it will be active for all request types.
120
+
But if you enable CSRF filter with public array $methods = ['POST' => ['csrf']];, the hidden CSRF field will not be added in GET requests.
116
121
117
122
**Adding Hidden Input Fields**
118
123
@@ -278,7 +283,7 @@ The following functions are available:
278
283
:param array $options: An associative array of options to be listed
279
284
:param array $selected: List of fields to mark with the *selected* attribute
280
285
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
281
-
:returns: An HTML multiselect (dropdown) element
286
+
:returns: An HTML select element with multiple attribute
282
287
:rtype: string
283
288
284
289
Lets you create a standard multiselect field. The first parameter will
@@ -403,7 +408,7 @@ The following functions are available:
403
408
:param string $data: Button name
404
409
:param string $value: Button value
405
410
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
406
-
:returns: An HTML input reset button element
411
+
:returns: An HTML input reset element
407
412
:rtype: string
408
413
409
414
Lets you generate a standard reset button. Use is identical to
@@ -452,10 +457,10 @@ The following functions are available:
452
457
:returns: Field value
453
458
:rtype: string
454
459
455
-
Permits you to set the value of an input form or textarea. You must
460
+
Permits you to set the value of an input or textarea element. You must
456
461
supply the field name via the first parameter of the function. The
457
462
second (optional) parameter allows you to set a default value for the
458
-
form. The third (optional) parameter allows you to turn off HTML escaping
463
+
field value. The third (optional) parameter allows you to turn off HTML escaping
459
464
of the value, in case you need to use this function in combination with
460
465
i.e., :php:func:`form_input()` and avoid double-escaping.
0 commit comments