0

I have the following Laravel 4.2 controller code in a store method:

if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } 

I've tested this code with var_dump and the $validator is definitely returning the correct error messages.

The errors however are not being passed to the view. When attempting var_dump($errors) on the view I get the following exception Undefined variable: errors.

I've also tried (by accident) var_dump($error)and it is of type object(Illuminate\Support\ViewErrorBag) however it does not contain any errors.

Does anyone know what the problem might be? Thanks in advance.

2
  • Show the code you have. $errors is shared view variable and it's always defined, unless you mess with the ViewServiceProvider. Commented Dec 31, 2014 at 18:17
  • @JarekTkaczyk Yes, you are 100% right, we don't need to check $errors variable. Sorry about that comment. John this should give error var_dump($error) but I believe this is a typo. Happy New year guys. Commented Dec 31, 2014 at 19:23

1 Answer 1

1

After looking into this issue for two whole days - I've finally fixed it! In the end I removed the vendor folder and ran composer update. I can only assume that something within Laravel was corrupt in the initial download.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.