I've just started to test out Laravel. I'm using a form with some fields and trying to validate the inputs using Laravel's built-in validator class.
$input = Input::all();
$rules = array(
'fname' => 'required|max:100',
'lname' => 'required|max:100',
'email' => 'required|email',
);
$validation = Validator::make($input, $rules);
if ($validation->fails()){
return Redirect::to('inputform')
->with('input_errors', $validation->errors);
}
Everything goes well, and the validation check works. When validation fails, I put the errors in a session variable called input_errors
and pass it to the view. My problem is that I can't seem to display the errors. I tried a foreach
loop using the blade templating engine
as given below:
@foreach (Session::get('input_errors') as $message)
{{ What Should I put here? }}
@endforeach
How can I display the errors that are being returned as an array. I tried referencing it as $message[0][0]
but it didn't work.
Thanks.
EDIT: Sorry, forgot to mention that I'm using Laravel 3