Redirect Back with Value - 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: Redirect Back with Value (/showthread.php?tid=77625) |
Redirect Back with Value - 68thorby68 - 09-25-2020 Hi, Is it possible to use redirect()->back(), with a value. I have a process that requires 2 forms. Form 1 allows the user to define a date and passes it to Form 2 Form 2 retrieves data from the database (based on the date from Form 1) , allows the user to manipulate the data, then writes the result back to the database. The problem is, I cannot redirect()->back() during the write process as I get cuaght in an infinite loop. I understand why I get caught in the loop, I'm just wondering if there is a way of passiing a value back with the redirect, so I avoid the infinite loop??? Any suggestions please Form 1 - View PHP Code: <form action="Form2" method="POST" enctype="multipart/form-data"> Form 2 - Controller PHP Code: class Form2 extends BaseController { Form 2 - View PHP Code: <form action="Form2/update" method="POST" enctype="multipart/form-data"> RE: Redirect Back with Value - InsiteFX - 09-27-2020 You can try this it uses the old in the froms. PHP Code: // Keep the old input values upon redirect so they can be used by the `old()` function RE: Redirect Back with Value - 68thorby68 - 09-28-2020 Thank you. I use this all the time, and it works very well. The issue is, that when Code: return redirect()->back()->withInput(); Is there a way of passing the original variable in the redirect so my controller can process? RE: Redirect Back with Value - jozefrebjak - 01-24-2022 "68thorby68" Are you solved this issue ? I have simmilar problem. I have one FORM in step 1 and some validation there. It's working fine. But when user go to Step 2 form and I want to make some validation there I cant. If I use route_to it will return to step 1 instead to step 2 and with back method it's infinite loop as you described. RE: Redirect Back with Value - sprhld - 01-24-2022 (01-24-2022, 07:05 AM)jozefrebjak Wrote: "68thorby68" Are you solved this issue ? I have simmilar problem. I have one FORM in step 1 and some validation there. It's working fine. But when user go to Step 2 form and I want to make some validation there I cant. If I use route_to it will return to step 1 instead to step 2 and with back method it's infinite loop as you described. Maybe you can manipulate the reason of the loop. Is there something in the request like checking the button which was clicked, or a hidden filed? Or you can stop the loop by check for the error-data? Just some ideas ;-) |