I am using Laravel 5 and I want to use input validation for my form. But my validation is not working. Do you know why?
Here is the view:
<div class="form-group"><br>
<label for="jenis_surat" class="control-label col-sm-2">Jenis Surat</label>
<div class="col-sm-7">
<script type="text/javascript">
@if($errors->any())
<div class="alert alert-danger">
@foreach($errors->all() as $error)
<p></p>
@endforeach
</div>
@endif
</script>
<input class="form-control" type="text" name="jenis_surat" id="jenis_surat">
</div>
<div class="col-md-1">
<input class="form-control" type="hidden" name="_token" value="">
<a class="btn btn-success" data-toggle="modal" data-target="#konfirmasi_submit_jenis_surat">Submit</a>
</div>
</div>
and this is the controller:
public function tambahjenissurat(Request $request)
{
//input validation
$this->validate($request, [
'jenis_surat' => 'required'
]);
$jenis_surat = $request['jenis_surat'];
$jenissurat = new JenisSurat();
$jenissurat->jenis_surat = $jenis_surat;
$jenissurat->save();
return redirect()->route('jenissurat');
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1rDONrv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire