What I'm trying to do is a basic validation after a form is submitted , i am using vuejs alongside with laravel but in the blade itself there is a form that gets submitted .
Upon submission we go into the controller the validate the stuff user sent, NOW here is the problem when one of the inputs are empty , then page goes in a redirect loop, resulting of "ERR_TOO_MANY_REDIRECTS".
the blade file that we need to be returned is "joborder/create" and we get send to store function to check the validation. I had to use create as a post so I overwrite the default from resource.
I have no idea whats causing the loop. I'm using laravel 5.2
Any help would be highly appreciate it.
Route :
Route::resource('joborder' ,'JoborderController');
Route::POST('joborder/create','JoborderController@create');
Blade File :
<div class="pubdiv col-md-12" >
{!! Form::open(['action' => 'JoborderController@store','method' =>'POST']) !!}
<h3>basicinput</h3>
<div class="row">
<div class="col-sm-3 col-xs-6 pull-right">
<div class="form-group">
{!! Form::label('company' , 'ComapnyName')!!}
<input type="text" class="form-control " name="owner" value="" disabled>
</div>
<div class="form-group ">
<input type='submit' value="finish" name="submit" style="margin-top:4px" class="col-md-12 btn btn-t-primary btn-theme">
</div>
{!! Form::close() !!} <!-- end form post a job -->
Controller :
if(session()->get('role_active') != 1){
return redirect('thehood')->with('error','NO CAN DO');
}else{
$this->validate($request, [
'alljobs_id' => 'required',
'joborder_id' => 'required',
'notes'=>'required',
'state' =>'required',
'city' => 'required',
'type' => 'required',
'salary' => 'required',
'created_at' => 'required',
]);
// after moving these remove the keys from request
$alljobs_id = $request->alljobs_id;
$joborder_id = $request->joborder_id;
$request->request->remove('joborder_id');
$request->request->remove('alljobs_id');
$check_prof + $check_prof_custom = 9;
if(($check_prof + $check_prof_custom < 5 ) || ($check_behv + $check_behv_custom < 5 )){
return redirect('joborder/create')->with('error','5 input is required!');
}
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2x8CSXz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire