Skip to content

Commit 49807bf

Browse files
authored
Merge pull request #7678 from kenjis/docs-old
docs: improve `old()` description
2 parents 8024ff9 + d8aef2c commit 49807bf

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

user_guide_src/source/general/common_functions.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Service Accessors
9494
If $data is a string, then it simply escapes and returns it.
9595
If $data is an array, then it loops over it, escaping each 'value' of the key/value pairs.
9696

97-
Valid context values: html, js, css, url, attr, raw
97+
Valid context values: ``html``, ``js``, ``css``, ``url``, ``attr``, ``raw``
9898

9999
.. php:function:: helper($filename)
100100
@@ -132,19 +132,21 @@ Service Accessors
132132
.. php:function:: old($key[, $default = null,[, $escape = 'html']])
133133
134134
:param string $key: The name of the old form data to check for.
135-
:param mixed $default: The default value to return if $key doesn't exist.
136-
:param mixed $escape: An `escape <#esc>`_ context or false to disable it.
135+
:param string|null $default: The default value to return if $key doesn't exist.
136+
:param false|string $escape: An `escape <#esc>`_ context or false to disable it.
137137
:returns: The value of the defined key, or the default value.
138-
:rtype: mixed
138+
:rtype: array|string|null
139139

140140
Provides a simple way to access "old input data" from submitting a form.
141141

142142
Example:
143143

144144
.. literalinclude:: common_functions/002.php
145145

146-
.. note:: If you are using the :doc:`form helper </helpers/form_helper>`, this feature is built-in. You only
147-
need to use this function when not using the form helper.
146+
.. note:: If you are using the :php:func:`set_value()`, :php:func:`set_select()`,
147+
:php:func:`set_checkbox()`, and :php:func:`set_radio()` functions in
148+
:doc:`form helper </helpers/form_helper>`, this feature is built-in. You only
149+
need to use this function when not using the form helper.
148150

149151
.. php:function:: session([$key])
150152

user_guide_src/source/general/common_functions/002.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
// in controller, checking form submittal
44
if (! $model->save($user)) {
5-
// 'withInput' is what specifies "old data"
6-
// should be saved.
5+
// 'withInput()' is what specifies "old data" should be saved.
76
return redirect()->back()->withInput();
87
}
98

0 commit comments

Comments
 (0)