wriggler's avatar

Lumen: error messages not passed to redirect destination

I'm having (another) strange problem with Lumen. When a validation error occurs, Lumen redirects to the previous page with the error messages bag object.

However, the $errors variable, and Session::get('errors') array, does not exist in the destination page.

I've tried both ways of validating.

  1. $this->validate($this->request, $rules);

  2. $v = \Validator::make($this->request->all(), $rules);

    if ($v->fails()) { return redirect()->back()->withErrors($v->errors()); }

Sessions are enabled and appear to be working: I can set and retrieve data I set myself. The validation error messages are there in $v->errors() when I print_r just after the validator has run and before the redirect. Any ideas on what I could be doing wrong?

Thanks,

0 likes
2 replies
bestmomo's avatar

I dont understand this :

$this->validate($this->request, $rules)

Where is this code ?

wriggler's avatar

That's shorthand in Lumen to validate the input. I didn't include the $rules etc because the validation is working, errors are created correctly, and is not the problem. The problem is with the redirect response, which isn't passing data correctly to the destination route.

Please or to participate in this conversation.