Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 966 dot array in old() function #969

Merged
merged 3 commits into from
Mar 21, 2018
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
24 changes: 23 additions & 1 deletion system/HTTP/IncomingRequest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public function getUserAgent()
/**
* Attempts to get old Input data that has been flashed to the session
* with redirect_with_input(). It first checks for the data in the old
* POST data, then the old GET data.
* POST data, then the old GET data and finally check for dot arrays
*
* @param string $key
*
Expand All @@ -490,6 +490,28 @@ public function getOldInput(string $key)
{
return $_SESSION['_ci_old_input']['get'][$key];
}

helper('array');

// Check for an array value in POST.
if (isset($_SESSION['_ci_old_input']['post']))
{
$value = dot_array_search($key, $_SESSION['_ci_old_input']['post']);
if ( ! is_null($value))
{
return $value;
}
}

// Check for an array value in GET.
if (isset($_SESSION['_ci_old_input']['get']))
{
$value = dot_array_search($key, $_SESSION['_ci_old_input']['get']);
if ( ! is_null($value))
{
return $value;
}
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/general/common_functions.rst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ Service Accessors

// In the view
<input type="email" name="email" value="<?= old('email') ?>">
// Or with arrays
<input type="email" name="user[email]" value="<?= old('user.email') ?>">

.. 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.
Expand Down