0
votes

I know this is duplicate problem. Still I'm not able to correct this problem so can anyone help?

Routes.php

   Route::post('/form-submit',[
   'uses' => 'UserController@formSubmit',
   'as' => 'f.submit',
]);

UserController.php

public function formSubmit() #form-submit
{
   echo"Form Submit Method";
}

test_view.php

@extends('Layout.master')
@section('Content')
 {!! Form::open([
         'route' => 'f.submit', 'method' => 'post'
 ]) !!}
  {!! Form::test('username') !!}
  {!! Form::submit('submit')!!}
 {!! Form::close() !!}
@endsection

If I'm using get method for this code. then directly it is showing Form Submit Method and if I'm using post method then it is showing above error

3
I've never used Laravel so you might be doing something advanced. Anyways, according to laravel.com/docs/5.4/routing I am finding no examples which are passing an array into the second parameter. The second parameter is supposed to be a callback so you either need an anonymous function or the name of an accessible function within the scope.MonkeyZeus
It would be in your best interest to specify which Laravel version you are using...MonkeyZeus
Route::post('/form-submit', 'UserController@formSubmit' ); I tried this one also even with anonymous function.Giridhari Lal
Laravel 5.2 versionGiridhari Lal
Well that's frustrating. laravel.com/docs/5.2/routing#named-routes shows array usage but laravel.com/docs/5.4/routing#named-routes does not. Good luckMonkeyZeus

3 Answers

1
votes

You need to pass a csrf token along the request within the form.

0
votes

i think

 //change '/form-submit' to 'f.submit'
    Route::post('/f.submit',[
       'uses' => 'UserController@formSubmit',
       'as' => 'f.submit',
    ])

and add csrf token also

0
votes

I was getting directly "Form Submit Method" rather than it should open test_view form. I have a solution for it using POST or GET method.

    Route::post('/form-submit',['
        'uses' => 'UserController@formSubmit'
        'as' => 'f.submit'
  ']});

But POST method still not working.