I'm not sure how to post it so it's helpful. There is a lot going on in the view.
I'm not able to return anything from the controller method actually anymore...unless I use dump & die. Why would that be?
example (doesn't work):
public function postApplication($type){
if ( $validation->passes() ) {
//do something here
} else {
Redirect::to(URL::previous());
}
}
example (works):
public function postApplication($type){
if ( $validation->passes() ) {
//do something here
} else {
dd(URL::previous());
}
}
you need to return the Redirect::to(URL::previous());
if ( $validation->passes() ) {
//do something here
} else {
return Redirect::to(URL::previous());
}
No luck there either. It just loads a blank page and never redirects anywhere.
I've tried: return Redirect::to(URL::previous()); return Redirect::back(); return Redirect::action();
I get the previous url, but nothing is rendered on the page.
Nothing happened with return URL::previous(); either....so bizarre.
if you can paste your views page to see what going on.
You can try this
return Redirect::to(URL::previous())->withInput()->withErrors($validation);
did you try this?
return Redirect::to(URL::previous())->withInput()->withErrors($validation);
remove you views page in this thread.
Yes, I did...didn't affect anything unfortunately.
did you get blank page again? try to view source.
Even if I do:
return View::make('index');
I get nothing.
are you putting something in the first block? it might be there are no errors?
if ( $validation->passes() ) {
//nothing is in here
//so you get a blank page
} else {
return Redirect::to(URL::previous())->withInput()->withErrors($validation);
}
I had the same problem. Turned out I used
Redirect::back()->withErrors($validator)->withInput();
and constantly received white pages instead of being redirected back. Only worked once I explicitly used a return statement
return Redirect::back()->withErrors($validator)->withInput();
May seem like a silly thing to overlook, but if you're having the same problem it's worth ruling out...
return Redirect::back()->withErrors($validator)->withInput();
is problematic when you add setStatusCode(422)
to it: result creates separate response page with redirection warning in it and then redirects:
return Redirect::back()->withErrors($validator)->withInput()->setStatusCode(422);
I know this is an old thread, but for anybody who finds this thread still having issues, make sure the Redirect isn't in a closure for another function.
For example:
Excel::load($filename, function ($reader) {
... some other code ...
return Redirect::back()->withErrors($errors);
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community