Answer the question
In order to leave comments, you need to log in
Laravel 5: Why am I getting an intermediate page on redirect?
Hello. There is this code with a simple form validation, which is placed on the page:
if($request->filter){
$v = Validator::make($request->all(), (new Requests\HypothecCalcRequest())->rules(), (new Requests\HypothecCalcRequest())->messages());
if ($v->fails()){
return redirect()->back()->withErrors($v->errors());
} else {
$calculatorTable = Hypothec::annuitCalculator($request);
}
}
....
return view('hypothec.index', $params);
Answer the question
In order to leave comments, you need to log in
I checked, there are no echo, var_dump, dump, dd outputs, nothing like that. Validation takes place at the very beginning of the method, there is no code before it.
The "intermediate" page appears if the redirect was not a HEAD (GET) method.
That is, in your case, when sending data using the POST method and passing the validation, you throw out a redirect to the GET method and everything is fine ...
But if the validation fails, you redirect to the same page using the POST method.
Roughly speaking, if after submitting the form you press F5 in the browser, then an alert will pop up in the browser itself: Resend data? - Should sound familiar...
So in this case RedirectResponse does an explicit GET redirect. If this did not happen, then you would not be able to refresh the page after such a redirect - the browser would issue an alert.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question