Combine with() and withInput() during redirection - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Combine with() and withInput() during redirection (/showthread.php?tid=82160) |
Combine with() and withInput() during redirection - coderscvoen - 06-18-2022 I have a form which after submission, i would like to redirect back with a custom message and old inputs. The code below does the redirection unfortunately it does not return with the old data. PHP Code: return redirect()->back()->with("failed", "All fields are required!")->withInput(); Thanks RE: Combine with() and withInput() during redirection - luckmoshy - 06-18-2022 (06-18-2022, 05:50 AM)coderscvoen Wrote: I have a form which after submission, i would like to redirect back with a custom message and old inputs. The code below does the redirection unfortunately it does not return with the old data. This is the best way PHP Code: return redirect()->back()->withInput()->with("failed", "All fields are required!"); Code: <input type="email" name="data" value="<?= old('data') ?>"> https://codeigniter.com/user_guide/general/common_functions.html?highlight=old#old RE: Combine with() and withInput() during redirection - InsiteFX - 06-18-2022 If you use the form helper the old is built into it. This is the best way, is the way that Myth/Auth does it. RE: Combine with() and withInput() during redirection - coderscvoen - 08-03-2022 (06-18-2022, 09:13 AM)luckmoshy Wrote:(06-18-2022, 05:50 AM)coderscvoen Wrote: I have a form which after submission, i would like to redirect back with a custom message and old inputs. The code below does the redirection unfortunately it does not return with the old data. Sorry for the very delayed response. Thanks a lot; this helped. |