Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions user_guide_src/source/general/common_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Service Accessors
If $data is a string, then it simply escapes and returns it.
If $data is an array, then it loops over it, escaping each 'value' of the key/value pairs.

Valid context values: html, js, css, url, attr, raw
Valid context values: ``html``, ``js``, ``css``, ``url``, ``attr``, ``raw``

.. php:function:: helper($filename)

Expand Down Expand Up @@ -117,19 +117,21 @@ Service Accessors
.. php:function:: old($key[, $default = null,[, $escape = 'html']])

:param string $key: The name of the old form data to check for.
:param mixed $default: The default value to return if $key doesn't exist.
:param mixed $escape: An `escape <#esc>`_ context or false to disable it.
:param string|null $default: The default value to return if $key doesn't exist.
:param false|string $escape: An `escape <#esc>`_ context or false to disable it.
:returns: The value of the defined key, or the default value.
:rtype: mixed
:rtype: array|string|null

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

Example:

.. literalinclude:: common_functions/002.php

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

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

Expand Down
3 changes: 1 addition & 2 deletions user_guide_src/source/general/common_functions/002.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

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

Expand Down