Skip to content

Commit 2303685

Browse files
authored
Merge pull request #7136 from kenjis/fix-docs-form_helper.rst
docs: fix form_helper.rst
2 parents f7fcf28 + 3d19080 commit 2303685

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

user_guide_src/source/helpers/form_helper.rst

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,28 @@ forms.
99
:local:
1010
:depth: 2
1111

12+
*************
1213
Configuration
13-
=============
14+
*************
1415

15-
Since ``v4.3.0``, void HTML elements (e.g. ``<input>``) in ``form_helper`` functions have been changed to be HTML5-compatible by default and if you need to be compatible with XHTML, you must set the ``$html5`` property in **app/Config/DocTypes.php** to ``false``.
16+
Since v4.3.0, void HTML elements (e.g. ``<input>``) in ``form_helper`` functions have been changed to be HTML5-compatible by default and if you need to be compatible with XHTML, you must set the ``$html5`` property in **app/Config/DocTypes.php** to ``false``.
1617

18+
*******************
1719
Loading this Helper
18-
===================
20+
*******************
1921

2022
This helper is loaded using the following code:
2123

2224
.. literalinclude:: form_helper/001.php
2325

24-
Escaping field values
25-
=====================
26+
*********************
27+
Escaping Field Values
28+
*********************
2629

2730
You may need to use HTML and characters such as quotes within your form
2831
elements. In order to do that safely, you'll need to use
2932
:doc:`common function <../general/common_functions>`
30-
:func:`esc()`.
33+
:php:func:`esc()`.
3134

3235
Consider the following example:
3336

@@ -37,16 +40,17 @@ Since the above string contains a set of quotes, it will cause the form
3740
to break. The :php:func:`esc()` function converts HTML special
3841
characters so that it can be used safely::
3942

40-
<input type="text" name="myfield" value="<?= esc($string) ?>" />
43+
<input type="text" name="myfield" value="<?= esc($string) ?>">
4144

4245
.. note:: If you use any of the form helper functions listed on this page,
4346
and you pass values as an associative array,
4447
the form values will be automatically escaped, so there is no need
4548
to call this function. Use it only if you are creating your own
4649
form elements, which you would pass as strings.
4750

51+
*******************
4852
Available Functions
49-
===================
53+
*******************
5054

5155
The following functions are available:
5256

@@ -99,14 +103,14 @@ The following functions are available:
99103

100104
<form action="http://example.com/index.php/email/send" class="email" id="myform" method="post" accept-charset="utf-8">
101105

102-
If CSRF 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 one of the ``$attribute`` array:
103107

104108
.. literalinclude:: form_helper/007.php
105109

106110
will return::
107111

108112
<form action="http://example.com/index.php/u/sign-up" method="post" accept-charset="utf-8">
109-
<input type="hidden" id="my-id" name="csrf_field" value="964ede6e0ae8a680f7b8eab69136717d" />
113+
<input type="hidden" id="my-id" name="csrf_field" value="964ede6e0ae8a680f7b8eab69136717d">
110114

111115
.. 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.
112116

@@ -122,8 +126,8 @@ The following functions are available:
122126
The above example would create a form similar to this::
123127

124128
<form action="http://example.com/index.php/email/send" method="post" accept-charset="utf-8">
125-
<input type="hidden" name="username" value="Joe" />
126-
<input type="hidden" name="member_id" value="234" />
129+
<input type="hidden" name="username" value="Joe">
130+
<input type="hidden" name="member_id" value="234">
127131

128132
.. php:function:: form_open_multipart([$action = ''[, $attributes = ''[, $hidden = []]]])
129133
@@ -457,7 +461,7 @@ The following functions are available:
457461

458462
Example::
459463

460-
<input type="text" name="quantity" value="<?= set_value('quantity', '0') ?>" size="50" />
464+
<input type="text" name="quantity" value="<?= set_value('quantity', '0') ?>" size="50">
461465

462466
The above form will show "0" when loaded for the first time.
463467

@@ -500,8 +504,8 @@ The following functions are available:
500504

501505
Example::
502506

503-
<input type="checkbox" name="mycheck" value="1" <?= set_checkbox('mycheck', '1') ?> />
504-
<input type="checkbox" name="mycheck" value="2" <?= set_checkbox('mycheck', '2') ?> />
507+
<input type="checkbox" name="mycheck" value="1" <?= set_checkbox('mycheck', '1') ?>>
508+
<input type="checkbox" name="mycheck" value="2" <?= set_checkbox('mycheck', '2') ?>>
505509

506510
.. php:function:: set_radio($field[, $value = ''[, $default = false]])
507511
@@ -516,8 +520,8 @@ The following functions are available:
516520

517521
Example::
518522

519-
<input type="radio" name="myradio" value="1" <?= set_radio('myradio', '1', true) ?> />
520-
<input type="radio" name="myradio" value="2" <?= set_radio('myradio', '2') ?> />
523+
<input type="radio" name="myradio" value="1" <?= set_radio('myradio', '1', true) ?>>
524+
<input type="radio" name="myradio" value="2" <?= set_radio('myradio', '2') ?>>
521525

522526
.. php:function:: validation_errors()
523527

0 commit comments

Comments
 (0)