Laravel validation errors are appearing randomly in my view -
when submit form validation works randomly, mean appears , not, found out validation object returned controller not looped in view always. here code in view:
@if ($errors->any()) <ul class="alert alert-danger"> <ul> @foreach ($errors->all() $error) <li>{{ $error }}</li> @endforeach </ul> </ul> @endif
it randomly shows this:
object(illuminate\support\viewerrorbag)#651 (1) { ["bags":protected]=> array(1) { ["default"]=> object(illuminate\support\messagebag)#643 (2) { ["messages":protected]=> array(12) { ["province_code"]=> array(1) { [0]=> string(36) "the province code field required." } ["district_code"]=> array(1) { [0]=> string(36) "the district code field required." } ["training_provider"]=> array(1) { [0]=> string(40) "the training provider field required." } ["training_center"]=> array(1) { [0]=> string(38) "the training center field required." } ["classroom"]=> array(1) { [0]=> string(32) "the classroom field required." } ["course_leader"]=> array(1) { [0]=> string(36) "the course leader field required." } ["shift"]=> array(1) { [0]=> string(28) "the shift field required." } ["start_date"]=> array(1) { [0]=> string(33) "the start date field required." } ["end_date"]=> array(1) { [0]=> string(31) "the end date field required." } ["start_time"]=> array(1) { [0]=> string(33) "the start time field required." } ["end_time"]=> array(1) { [0]=> string(31) "the end time field required." } ["course_conduct_days"]=> array(1) { [0]=> string(42) "the course conduct days field required." } } ["format":protected]=> string(8) ":message" } } }<!doctype html>
and comes empty array!
object(illuminate\support\viewerrorbag)#652 (1) { ["bags":protected]=> array(0) { } }
do if message bag has errors printed
@if($errors->has()) <div class="alert alert-danger"> <ul> @foreach($errors->getmessages() $messages) @foreach($messages $message) <li>{{$message}}</li> @endforeach @endforeach </ul> </div> @endif
thanks :)
Comments
Post a Comment