0
votes

I get this issue when I submit a post form

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message

I have been reading about this issue and most people said that the route should be changed to post which I have from the start and I am getting this error

web.php:

Route::post('/new-trade/submit', 'NewTradesController@submit');

Controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class NewTradesController extends Controller
{
    public function submit(Request $request){
        return 123;
    }
}

Form:

{!! Form::open(['class' => 'needs-validation', 'novalidate', 'id' => 'new-trade-form', 'method' => 'post', 'files' => true]) !!}
2

2 Answers

0
votes

When you open a form, you are not specifying the action or url where form will post to. You can add action like :

{!! Form::open(['class' => 'needs-validation', 'url' => '/new-trade/submit', 'novalidate', 'id' => 'new-trade-form', 'method' => 'post', 'files' => true]) !!}

Also POST is the default method for form open. So you can remove 'method' => 'post' if you would like

-1
votes

You should try this:

{!! Form::open([url=>'/new-trade/submit','class' => 'needs-validation', 'novalidate', 'id' => 'new-trade-form', 'method' => 'post', 'files' => true]) !!}