Franklin Tanemou
Franklin Tanemou

Reputation: 21

a form with the PUT method is sent with the GET method

I have 2 controller with resource clients and sumsubs. being on the clients.show route I created a form that I would like to send to the sumsubs.update endpoint but it does not work; the form still contacts sumsubs.show

here are the routes that I have defined

here is the form

<form accept-charset="UTF-8" class="form-horizontal" name='recheck' method="PUT" action="{{ route('sumsubs.update', $client->id) }}">

      @csrf

      <div class="form-group row">
          <div class="col-sm-10">
               <input type="number" class="form-control" id="candidat" name="candidat" value="{{ $client->id }}" hidden required>
          </div>
      </div>
      <div class="card-footer">
          <button type="submit" class="btn btn-success float-right"> {{ __('Recheck') }} </button>
      </div>
</form>

the following is my sumbsubs controller

public function show($id)
{
  return 'not ok';
}


public function update(Request $request, $id)
{
        return 'ok ';
}

this is what i get when i submit the form

I would like to know where is my mistake

I read the laravel documentation for form submission and tried with url and route methods but I still get the same result

Upvotes: 0

Views: 40

Answers (1)

Hosein Shendabadi
Hosein Shendabadi

Reputation: 362

You have to use method spoofing. Change your method in form tag to Post:

<form accept-charset="UTF-8" class="form-horizontal" name='recheck' method="POST" action="{{ route('sumsubs.update', $client->id) }}">

and add this after @csrf:

@method('PUT')

Upvotes: 2

Related Questions