Welcome Guest, Not a member yet? Register   Sign In
Combine with() and withInput() during redirection
#1

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(); 
So i was wondering if it is possible to append withInput to with.
Thanks
Reply
#2

(This post was last modified: 06-18-2022, 09:19 AM by luckmoshy.)

(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.
PHP Code:
return redirect()->back()->with("failed""All fields are required!")->withInput(); 
So i was wondering if it is possible to append withInput to with.
Thanks

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/gener...ht=old#old
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#3

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(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.
PHP Code:
return redirect()->back()->with("failed""All fields are required!")->withInput(); 
So i was wondering if it is possible to append withInput to with.
Thanks

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/gener...ht=old#old

Sorry for the very delayed response. Thanks a lot; this helped.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB