Laravel - error messages that do not translate the actual error message begin with a "check".

I'm having trouble trying to get form validation working in Laravel, which is odd because it usually works.

In my user model, I created rules for checking:

public static $rules = array( 'firstname'=>'required|min:2|alpha', 'lastname'=>'required|min:2|alpha', 'email'=>'required|email|unique:users', 'password'=>'required|alpha_num|between:8,12|confirmed', 'password_confirmation'=>'required|alpha_num|between:8,12', 'telephone'=>'required|between:10,12', 'admin'=>'integer' ); 

In my user controller, I define actions only if the verification passes, if the user is not redirected back with errors:

 public function postCreate() { $validator = Validator::make(Input::all(), User::$rules); if ($validator->passes()) { $user = new User; $user->firstname = Input::get('firstname'); $user->lastname = Input::get('lastname'); $user->email = Input::get('email'); $user->password = Hash::make(Input::get('password')); $user->telephone = Input::get('telephone'); $user->save(); return Redirect::to('users/signin') ->with('message', 'Thank you for creating a new account. Please sign in.'); } return Redirect::to('users/create-account') ->with('message', 'Something went wrong') ->withErrors($validator) ->withInput(); } 

The following errors have occurred:

In the view, I display errors if they exist:

 @if($errors->has()) <div id="form-errors"> <p>The following errors have occurred:</p> <ul> @foreach($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div><!-- end form-errors --> @endif 

The problem I have is that the output of this when submitting an empty form is:

 validation.required validation.required validation.required validation.required validation.required validation.required 

Instead:

 The firstname field is required. The lastname field is required. The email field is required. The password field is required. The password confirmation field is required. The telephone field is required. 

If anyone can suggest why this is happening or what I am missing, then it will be very helpful!

+7
php validation localization laravel laravel-4
source share
4 answers

If this worked for you before then, you should check if you have messages defined in app\lang\en\validation.php , or, by chance, you changed the application locale and did not define messages for it. There are many possibilities.

+6
source share

I had a similar problem, and the problem is that I accidentally deleted Resources / languages ​​/ EN / validation.php

+4
source share

I had a similar problem when I set both the locale and the backup locale to a locale that didn't have a validation file in app.php. Try setting the backup locale to en or one that you are sure exists.

+2
source share

I had this problem. Check the lang directory, it should be placed in the resource directory.

I dragged the lang directory to another directory and then received the same validation response as you. The fix was simple to move it back to the resource directory.

+1
source share

All Articles