What is your session driver set to?
Can you try SESSION_DRIVER=file and see if that fixes it?
Laravel 8 - Problems with validation errors on large form [SOLVED]
Hi folks,
I have a Blade form with 35 input fields. Although, this can be more if the user chooses to extend the form by inserting additional sections.
When the form is submitted and validation errors are identified, there seems to be a limit on how many old_input fields can be passed on in the session object within the returned redirect. So, if I have the basic 35 old_input data fields saved in the session, then the validation errors and old_input are passed back to the blade file and can be displayed correctly. However, if I go over that by adding just 1 extra input field, then the validation errors and old_inputs are not passed back. The validation errors and old_input are completely missing from the session data after the redirect.
I get no errors in the laravel.log, or the webserver logs. I am using the file session driver but have also tried cookie and database. Neither did any better. I've also had exactly the same result running in both my dev environment using a Nginx docker container, and on the live environment running Apache. I can't seem to find any way to affect the limit.
By setting a breakpoint in the edit() method of my controller, I can see that the session data is passed back correctly following the redirect with just the 35 inputs, but errors and old_input are missing with any more than that. Setting a breakpoint in the update() method, I can also see that prior to the redirect being returned the session always appears to be correct and does hold all the errors and old_input items even with 36+ input fields.
Any help with understanding what is causing this would be very much appreciated.
I'm not trying anything fancy here. My controller's update() and edit() methods are very basic...
public function update(Request $request, SomeModel $someModel)
{
$validator = Validator::make($request->all(), [/*rules*/]);
if($validator->fails()) {
$redirect = redirect(route('someModel.edit', $someModel->id))
->withErrors($validator)
->withInput();
// Breakpoint here shows validation works fine with 36+ fields
return $redirect
}
// Validation passed
}
public function edit(SomeModel $someModel)
{
// Breakpoint here shows that the redirected session will only work with up to 35 fields
return view('someModel.edit')->with($someModel);
}
Please or to participate in this conversation.