getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
634 stars 95 forks source link

How I can redirect back with errors? #143

Open giwrgos88 opened 7 years ago

giwrgos88 commented 7 years ago

I have a route with two segments, that calls a form for storing. I want in case of an error to return back to the page with the inputs.

Here is my route

$router->get([
    'as'   => 'testingForm',
    'uri'  => '/testing/form/{parent_slug}/{child_slug}',
    'uses' => __NAMESPACE__ . '\Http\Controllers\Testing\Testing@form'
]);

and if the input data are not valid I have this but is not working

if ($validator->fails()) {
                $url = (string) $request->server()['HTTP_REFERER'];
                return redirect_response($url)->with('__form_data', $request->all())->with('error', $validator->messages());
}

Laravel has this to redirect back return redirect()->back()->withInput();

Does anyone knows how i can redirect back to my custom route?