Reputation: 1220
I have a very strange issue.
I worked fine but now when i try to post the datas with the submit button the form redirect my always to the create view without going the storeClub method.
here my form :
{!! Form::open(array('route' => 'store.club', 'method' => 'POST' , 'files' => true )) !!}
<div class="row">
<div class="form-group col-md-4">
<label>Nom * </label>
{!! Form::text('lb_nom', null, ['class' => 'form-control', 'placeholder' => 'Nom']) !!}
</div>
<div class="form-group col-md-5">
<label>Prénom *</label>
{!! Form::text('lb_prenom', null, ['class' => 'form-control', 'placeholder' => 'Prénom']) !!}
</div>
</div>
<div class="box-footer" data-step="5" data-intro='Une fois tout les éléments renseignés vous pouvez cliquer sur Enregistrer et votre licence sera directement envoyée dans le Panier.'>
{!! Form::submit('Enregistrer', ['class' => 'btn btn-info btn-lg center-block']) !!}
</div>
{!! Form::close() !!}
Here my routing :
Route::get('/create/club' , 'StructureController@createClub')->name('create.club');
Route::post('/save/club' , 'StructureController@storeClub')->name('store.club');
Here my create view :
public function createClub(Request $request){
//do something
return view('structure/createClub' , compact('type_structure' ,'structure_pere'));
}
here my store method that i can't call when i submit :
public function storeClub(Request $request){
//do something
}
what my doing wrong ? i have a lot of forms in the application who works fine like that
Upvotes: 0
Views: 42
Reputation: 868
use @csrf
After form tag:
{!! Form::open(array('route' => 'store.club', 'method' => 'POST' , 'files' => true )) !!}
@csrf
Upvotes: 0
Reputation: 10714
Don't you use any validation for your request ?
I think you have validation errors, but you don't display them, I got this problem.
Use in your view (before your form for example) :
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
If your request have errors, it will redirect to the previous page.
Upvotes: 2