Support the ongoing development of Laravel.io →
Requests Input Validation
Last updated 2 years ago.
0

can i see the view's code?

Last updated 2 years ago.
0

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());
	}
}
Last updated 2 years ago.
0

you need to return the Redirect::to(URL::previous());

    if ( $validation->passes() ) {
        //do something here
} else {
    return Redirect::to(URL::previous());
}
Last updated 2 years ago.
0

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();

Last updated 2 years ago.
0

what url did you get? the previous url?

Last updated 2 years ago.
0

can you try return URL::previous();

Last updated 2 years ago.
0

I get the previous url, but nothing is rendered on the page.

Nothing happened with return URL::previous(); either....so bizarre.

Last updated 2 years ago.
0

if you can paste your views page to see what going on.

Last updated 2 years ago.
0

You can try this

return Redirect::to(URL::previous())->withInput()->withErrors($validation);
Last updated 2 years ago.
0

did you try this?

return Redirect::to(URL::previous())->withInput()->withErrors($validation);

remove you views page in this thread.

Last updated 2 years ago.
0

Yes, I did...didn't affect anything unfortunately.

Last updated 2 years ago.
0

did you get blank page again? try to view source.

Last updated 2 years ago.
0

Yeah, view source is empty.

Last updated 2 years ago.
0

Even if I do:

return View::make('index');

I get nothing.

Last updated 2 years ago.
0

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);
}
Last updated 2 years ago.
0

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...

Last updated 9 years ago.
0

@Stekefanten:

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);
Last updated 9 years ago.
0

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);
});
0

Sign in to participate in this thread!

Eventy

Your banner here too?

mxalix258 mxalix258 Joined 20 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.