php - Laravel MethodNotAllowedHttpException -


i creating website that, once user arrives, greeted form input unique id , dob. upon entering information , clicking submit, sent main form has little information on , user must enter rest. problem arises when try submit form keep getting following error:

at routecollection->methodnotallowed(array('post', 'patch')) 

note: not want variables in routes. (ex: want 'form/person' , not 'form/{person_id}'). also, have included relavent information regarding errors.

gate.blade.php - (this user enters id , date of birth):

{!! form::open(array('action' => 'jurorscontroller@form', 'class' => 'form-inline')) !!} 

form.blade.php - (this primary form user must fill out , submit):

{!! form::open(['url' => action('jurorscontroller@submit'), 'method' => 'patch', 'class' => 'form-inline']) !!} 

routes.php:

route::patch('jurors/form', 'jurorscontroller@submit'); route::get('jurors', 'jurorscontroller@gate'); route::post('jurors/form', 'jurorscontroller@form'); 

jurorcontroller@submit

public function submit(formsubmitrequest $request) {     //never reaches point nor executes submit... instead redirects gate if doesn't return 'methodnotallowedhttpexception' error.     dd($request); } 

the time managed not show me 'methodnotallowedhttpexception' exception, instead got redirected gate.blade.php page. if have questions me or need me clerify on anything, leave me comment , respond once able to.

thanks.

it looks me problem url in our routes. repeating them.

firstly recommend using named routes give bit more definition between routes. i'd change routes to

route::put('jurors/submit',[     'as' => 'jurors.submit',     'uses' => 'jurorscontroller@submit' ]);  route::get('jurors',[     'as' => 'jurors.gate',     'uses' => 'jurorscontroller@gate' ]);  route::post('jurors/form', [     'as' => 'jurors.form',     'uses' => 'jurorscontroller@form' ]); 

also on submit route why using patch request. wouldn't use post request data in? if still need use patch should using put instead in routes. way for testing , debugging use any see if http request causing error example

route::any('jurors/submit',[         'as' => 'jurors.submit',         'uses' => 'jurorscontroller@submit'     ]); 

also can use name of route in form::open() example

{!! form::open(array('route' => 'jurors.form', 'class' => 'form-inline')) !!} 

hope helps


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -