Form
Persistent form data after submission.
This is useful when you want to validate the form after it has been submitted. It makes it more user friendly in the sense that the user does not have to re-populate certain pieces of information if they do something incorrectly. To maintain form data after the submission action, save the form data to the session named form
:
if ($blob = Post::get('blob')) {
if (!empty($blob['error'])) {
// Store all form data to session
Session::set('form', Post::get());
} else {
// Clear all form session on success
Session::let('form');
}
}
The following is an example of generic HTML form markup:
<form enctype="multipart/form-data" method="post">
<p>
<input name="blob" type="file">
</p>
<p>
<!-- These two fields will have persistent form data. -->
<input name="file[name]" type="text">
<input name="file[x]" type="text">
</p>
<p>
<button type="submit">Upload</button>
</p>
</form>