0

I am working on a laravel project and I am having some issues with the validation. The default error messages dont appear instead I get to see the validation requirements like this: http://gyazo.com/681e9d8e2e176a29d90db041354f7177

this is my code:

routes.php (I put all the code in here for now)

Route::filter('checkLogin', function()
{


   if(Input::GET('email') != ""){ //register


        $rules =
        array(
            'username' => 'required|max:64|min:3|unique:users',
            'password' => 'required|max:64|min:6',
            'fname' => 'required|max:255|alpha',
            'lname' => 'required|max:255|alpha',

            'email' => 'required|max:255|email',
            'phone' => 'max:24|min:9',
            'zip' => 'required',
            'street' => 'required|max:255|alpha',
            'housenumber' => 'required|max:6|numeric',
            'country' => 'required',
            'avatar' => 'max:32'
       );


    $validator = Validator::make(Input::all(), $rules);
    if($validator->fails()) {
        return Redirect::to('/')->withInput()->withErrors($rules);
    }
}

});

this is how the code from the view:

                   <div class="fields">
                        <div class="field">
                            <i class="fa fa-user"></i>
                            {{ Form::text('username', null, ['placeholder' => 'Username', 'tabindex' => 1]) }}
                            {{ $errors->first('username') }}

                        </div>
                        <div class="field">
                            <i class="fa fa-lock"></i>
                            {{ Form::password('password', ['placeholder' => 'Password', 'tabindex' => 2]) }}
                            <a href="forgot" class="fa fa-question-circle login" title="Forgot Password?"></a>
                            {{ $errors->first('password') }}
                        </div>
                    </div>

1 Answer 1

1

When validation fails, you are returning your $rules as the errors. Change this line:

return Redirect::to('/')->withInput()->withErrors($rules);

to this:

return Redirect::to('/')->withInput()->withErrors($validator);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.