Ich versuche, die Kundenwerte in der Datenbank über die untenstehende Laravel View PHP zu speichern. Wenn ich Route::post('/directory', '[email protected]');
in der routes.php
mache, dann bekomme ich eine Exception "MethodNotAllowedHttpException"
. Aber ich mache "Route::get('/directory', '[email protected]');"
dann keine Ausnahme und die richtige Methode in TaskController wird aufgerufen. Was ich nicht verstehe, obwohl ich die Formularmethode als POST habe, sende das Formular mit GET. Ich bin neu in Laravel, entschuldige meine Unwissenheit hier.Warum wird dieses Laravel Formular GET'ed nicht POST bekommen
Ich benutze Bootstrap Pager/Wizard-Klasse, um die Kundendaten zu übermitteln. Nicht sicher, ob das einen Unterschied macht.
<form action="{{url('/directory' . $Customer->id)}}" method="POST">
{{ csrf_field() }}
<div class="form-group">
<ul class="nav nav-pills">
<li class="active"><a href="#basic-tab" data-toggle="tab">Customer Details</a></li>
<li><a href="#database-tab" data-toggle="tab">Directory Configuration</a></li>
</ul>
</div>
<!-- Current Tasks -->
@if (count($Customer) > 0)
<div class="panel panel-default">
<div class="panel-heading">
Customer Details
</div>
<div class="panel-body">
<div class="form-group">
<label for="customer-name">Name</label>
<input type="text" class="form-control" id="customer-name" value="{{ $Customer->name }}">
</div>
<div class="form-group">
<label for="customer-email">Email</label>
<input type="text" class="form-control" id="customer-email" value="{{ $Customer->email }}">
</div>
<div class="form-group">
<label for="customer-street">Street</label>
<input type="text" class="form-control" id="customer-street" value="{{ $Customer->street }}">
</div>
<div class="form-group">
<label for="customer-post_code">PostCode</label>
<input type="text" class="form-control" id="customer-post_code" value="{{ $Customer->post_code }}">
</div>
<div class="form-group">
<label for="customer-country">Country</label>
<input type="text" class="form-control" id="customer-country" value="{{ $Customer->country }}">
</div>
<!-- Previous/Next buttons -->
<ul class="pager wizard">
<li class="previous disabled"><a>Previous</a></li>
<li class="next"><a href="/directory">Next</a></li>
</ul>
</div>
</div>
@endif
</form>
Was haben Sie mit der 'route' gemacht, als das Formular abgeschickt wurde? Haben Sie 'Route :: post ('YOUR_URL', 'CONTROLLER @ FUNCTION') verwendet?' – Regolith
Es sieht so aus, als ob die folgende Anweisung immer einen GET '