Laravel does not generate error while processing form with 'post'

Asked

Viewed 83 times

-2

I’m taking a course of Laravel, and in the course the instructor used a form that points nowhere to show a mistake of the type MethodNotAllowedHttpException. Until then, fine, but when processing the form Laravel does not generate any error, while that of the instructor, with the same code, generates. Why?

Page template:

<!DOCTYPE html>
<html lang="pt-BR">
  <head>
    <meta charset="utf-8"/>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"/>
    <title>Controle de Series</title>
  </head>
  <body>
    <div class="container">
      <div class="jumbotron">
        <h1>@yield('cabecalho')<!-- local onde sera inserido o cabecalho da pagina --></h1>
      </div>

      @yield('conteudo') <!-- local onde sera inserido o conteudo da pagina -->
    </div>
  </body>
</html>

Page of the form:

@extends('layout')
@section('cabecalho')
Adicionar Serie
@endsection

@section('conteudo')
<form method="post">
    <div class="form-group">
        <label for="nome">Nome</label>
        <input type="text" name="nome" id='nome' class='form-control'/>
    </div>

    <button class='btn btn-primary'>Adicionar</button>
</form>
@endsection

I’m using Laravel 5.8, with PHP 7.3.5

1 answer

1


I believe that MethodNotAllowedHttpException is a route error in Laravel, maybe it is using POST and you are using GET. Open your route file and check.

But a basic example would be like this.

Route::post("/first_page",function(){
     return view('welcome');
})

If you add to your URL /first_page it will make a mistake of MethodNotAllowedHttpException on account that you should access the route as POST and not by GET.

  • Error it will still continue giving notfound missed by @csrf after the form opening

  • Yes I agree, but I think the question has been edited so it may have existed @csrf.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.