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 :ref:`filters-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
@@ -145,7 +150,7 @@ The following functions are available:
145
150
146
151
:param string $name: Field name
147
152
:param string $value: Field value
148
-
:returns: An HTML hidden input field tag
153
+
:returns: An HTML hidden input element
149
154
:rtype: string
150
155
151
156
Lets you generate hidden input fields. You can either submit a
@@ -171,7 +176,7 @@ The following functions are available:
171
176
:param string $value: Field value
172
177
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
173
178
:param string $type: The type of input field. i.e., 'text', 'email', 'number', etc.
174
-
:returns: An HTML text input field tag
179
+
:returns: An HTML text input element
175
180
:rtype: string
176
181
177
182
Lets you generate a standard text input field. You can minimally pass
@@ -206,7 +211,7 @@ The following functions are available:
206
211
:param array $data: Field attributes data
207
212
:param string $value: Field value
208
213
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
209
-
:returns: An HTML password input field tag
214
+
:returns: An HTML password input element
210
215
:rtype: string
211
216
212
217
This function is identical in all respects to the :php:func:`form_input()`
@@ -217,7 +222,7 @@ The following functions are available:
217
222
:param array $data: Field attributes data
218
223
:param string $value: Field value
219
224
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
220
-
:returns: An HTML file upload input field tag
225
+
:returns: An HTML file upload input element
221
226
:rtype: string
222
227
223
228
This function is identical in all respects to the :php:func:`form_input()`
@@ -229,7 +234,7 @@ The following functions are available:
229
234
:param array $data: Field attributes data
230
235
:param string $value: Field value
231
236
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
232
-
:returns: An HTML textarea tag
237
+
:returns: An HTML textarea element
233
238
:rtype: string
234
239
235
240
This function is identical in all respects to the :php:func:`form_input()`
@@ -244,7 +249,7 @@ The following functions are available:
244
249
:param array $options: An associative array of options to be listed
245
250
:param array $selected: List of fields to mark with the *selected* attribute
246
251
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
247
-
:returns: An HTML dropdown select field tag
252
+
:returns: An HTML select (dropdown) element
248
253
:rtype: string
249
254
250
255
Lets you create a standard drop-down field. The first parameter will
@@ -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 dropdown multiselect field tag
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
@@ -326,7 +331,7 @@ The following functions are available:
326
331
:param string $value: Field value
327
332
:param bool $checked: Whether to mark the checkbox as being *checked*
328
333
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
329
-
:returns: An HTML checkbox input tag
334
+
:returns: An HTML checkbox input element
330
335
:rtype: string
331
336
332
337
Lets you generate a checkbox field. Simple example:
@@ -357,7 +362,7 @@ The following functions are available:
357
362
:param string $value: Field value
358
363
:param bool $checked: Whether to mark the radio button as being *checked*
359
364
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
360
-
:returns: An HTML radio input tag
365
+
:returns: An HTML radio input element
361
366
:rtype: string
362
367
363
368
This function is identical in all respects to the :php:func:`form_checkbox()`
@@ -368,7 +373,7 @@ The following functions are available:
368
373
:param string $label_text: Text to put in the <label> tag
369
374
:param string $id: ID of the form element that we're making a label for
370
375
:param string $attributes: HTML attributes
371
-
:returns: An HTML field label tag
376
+
:returns: An HTML label element
372
377
:rtype: string
373
378
374
379
Lets you generate a <label>. Simple example:
@@ -387,7 +392,7 @@ The following functions are available:
387
392
:param string $data: Button name
388
393
:param string $value: Button value
389
394
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
390
-
:returns: An HTML input submit tag
395
+
:returns: An HTML input submit element
391
396
:rtype: string
392
397
393
398
Lets you generate a standard submit button. Simple example:
@@ -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 tag
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
@@ -414,7 +419,7 @@ The following functions are available:
414
419
:param string $data: Button name
415
420
:param string $content: Button label
416
421
:param mixed $extra: Extra attributes to be added to the tag either as an array or a literal string
417
-
:returns: An HTML button tag
422
+
:returns: An HTML button element
418
423
:rtype: string
419
424
420
425
Lets you generate a standard button element. You can minimally pass the
@@ -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