2

I have a form with "email" field. If the email field is blank then I want to redirect back to the same form with the alert message. I have tried the code

return Redirect::back()
                    ->withErrors($validator)
                    ->withInput();

It gets redirected to the desired page but i am getting MethodNotAllowedHttpException in RouteCollection.php line 218: this error. I am getting the alert message as desired once i click on the back button of the browser. How to resolve this?

prajakta
  • 117
  • 1
  • 3
  • 12
  • I think you are getting that error because you are POSTing to a GET route. for clarifications [Here](http://stackoverflow.com/questions/19760585/laravel-throwing-methodnotallowedhttpexception) – Maraboc Jul 04 '16 at 11:30
  • I have described the functions in the route.php as this: Route::get('dramareport', 'ReportsController@dramareport'); Route::post('d_report', 'ReportsController@d_report'); I refereed to the link as you shown but i didn't get the idea. – prajakta Jul 04 '16 at 11:47
  • In which url you are getting the error? is it `/dramareport` ? – Maraboc Jul 04 '16 at 11:53
  • What is your form `action` attribute content? – Maraboc Jul 04 '16 at 12:11
  • {!! Form::open(['url' => 'send_mail', 'class' => 'form-horizontal','onsubmit'=>'myFunction()']) !!} this is how i have declared the form – prajakta Jul 04 '16 at 12:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/116371/discussion-between-prajakta-and-maraboc). – prajakta Jul 04 '16 at 12:19

1 Answers1

0

You can return the errors like this also

return Redirect::to('/yout/path/here/')
                        ->withErrors($validator)
                        ->withInput();
Qirel
  • 25,449
  • 7
  • 45
  • 62
Bindesh Pandya
  • 193
  • 3
  • 14