T
T
The Dragger2015-06-12 00:04:57
Laravel
The Dragger, 2015-06-12 00:04:57

Validation not working?

AuthController

public function postLogin()
    {
        $data = Input::all();
        $rules = array(
            'username' => 'required',
            'password' => 'required',
        );
        $validator = Validator::make($data, $rules);
        if ($validator->fails()) {
            return redirect(route('postLogin'))->withErrors($validator)->withInput();
        }
    }

view
@extends('todo.layouts.default')
@section('content')
Login
@foreach($errors->all as $error)
<div class="errors">{{ $error[0] }}</div>
@endforeach

    {!! Form::open() !!}
        <input type="text" name="username" placeholder="UserName"/>
        <input type="text" name="password" placeholder="passowrd"/>
        <button type="submit">Отправить</button>
    {!! Form::close() !!}
@endsection

There is a clear validation of 'username' => 'required',
'password' => 'required',
when I send empty inputs, a redirect is triggered, but there are no errors in the view, what's wrong? everything according to the documentation. Maybe it's all about $errors ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-06-12
@IPD2

@foreach($errors-> all() as $error)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question