Skip to content

Commit

Permalink
Merge pull request #969 from gabpnr/fix/issue-966
Browse files Browse the repository at this point in the history
Fix issue 966 dot array in old() function
  • Loading branch information
lonnieezell authored Mar 21, 2018
2 parents f999435 + cd31a89 commit 99c5443
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit 99c5443

Please sign in to comment.