mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Automatically inject validation errors from withInput() into view data. Default view to saveData = true for better usability.
This commit is contained in:
parent
9872a8c2ea
commit
2a781e599b
@ -10,7 +10,7 @@ class View extends \CodeIgniter\Config\View
|
||||
* calls so that it is available to all views. If that is the case,
|
||||
* set $saveData to true.
|
||||
*/
|
||||
public $saveData = false;
|
||||
public $saveData = true;
|
||||
|
||||
/**
|
||||
* Parser Filters map a filter name with any PHP callable. When the
|
||||
|
@ -117,6 +117,13 @@ if ( ! function_exists('view'))
|
||||
unset($options['saveData']);
|
||||
}
|
||||
|
||||
// Automatically inject any validation errors into the view
|
||||
// that may have come from 'redirect()->withInput()'.
|
||||
if (isset($_SESSION) && ! empty($_SESSION['errors']))
|
||||
{
|
||||
$data['errors'] = $_SESSION['errors'];
|
||||
}
|
||||
|
||||
return $renderer->setData($data, 'raw')
|
||||
->render($name, $options, $saveData);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user