lundi 28 septembre 2015

Laravel 5 : Validation error message not working?

I can print error message in views with this code

return Redirect::back()->withInput()->withErrors($v);

Here is my view

@if(Session::has('errors'))
    <div class="row">
        <div class="col-md-12 col-sm-12">
            <div class="alert alert-warning">
                <button class="close" data-close="alert"></button>
                <ul>
                @foreach($errors->all() as $error)
                <li><strong>{{ $error }}</li></strong>
                @endforeach
                </ul>
            </div>
        </div>
    </div>
@else
        no error
@endif

But I can't print error if I use this code instead

return Redirect::back()->withInput()->withCok($v);

Here is the view

@if(Session::has('cok'))
    <div class="row">
        <div class="col-md-12 col-sm-12">
            <div class="alert alert-warning">
                <button class="close" data-close="alert"></button>
                <ul>
                @foreach($cok->all() as $error)
                <li><strong>{{ $error }}</li></strong>
                @endforeach
                </ul>
            </div>
        </div>
    </div>
@else
        no error
@endif

I always get no error.

  1. So how I can use withCok($v) instead of withErrors($v)?
  2. Why this thing happen ?
  3. Is this because withCok($v) does not create $cok variable ? while $errors already there by default ?


from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ODyqTY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire