Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

chrisan's avatar

Is there a max size for forms and validation via session flash?

I have a lengthy form, about 40-50 flags for a model we store in the database.

As I was adding fields I noticed my errors stopped appearing sometime during development of this form using this to output the errors:

@if ($errors->any())
  <div class="alert alert-danger">
    <ul>
      @foreach ($errors->all() as $error)
        <li>{{ $error }}</li>
      @endforeach
    </ul>
  </div>
@endif

I thought typo or some other logic and kept removing fields one by one and then it worked again. OK, so back to working form an errors showing. I add 1 more field and poof, no more errors show.

Here is the controller, nothing special

public function update(Request $request, Company $company) {
//    try {
  $validatedAttributes = $request->validate([
    'name' => ['required','max:255'],
    'key' => ['required','max:255'],
    'active' => ['required', 'boolean'],
    'tracking' => ['required']
  ]);
//    }
//    catch (\Exception $e) {
//      dd($e);
//    }

  $company->update($validatedAttributes);
  $this->flash('success',$company->name . ' was updated!');
  return redirect(route('companys.edit', $company));
}

Now when I enable the try catch, the errors show up in the dump. But they never make it to the flashed session

If I delete the new field again, then again errors show.

I add different "one more" field, and surprise, errors back.

The fields are exactly the same except for their names. Here is an example

<label class="col-sm-2 col-form-label" for="foo_bar_baz_qux_qwerty">Sale Price</label>
<div class="col-sm-4">
  <select name="foo_bar_baz_qux_qwerty" id="foo_bar_baz_qux_qwerty" class="form-control m-b">
    <option value="foobar">foobar</option>
  </select>
</div>

OK so 1 field works but the other doesn't. Its all the same format.

I take the working field and rename it to the last field that made errors go away. Try again and yup, errors are gone.

Extremely baffled I now remove a character from the name 1 letter at a time and somewhere through it errors appear again.

I further test and put the name back to original and then remove characters from the value of the select and again suprise, errors gone again.

I seem to have hit some hard limit on the error object. The above field DOES NOT work. But EITHER of these 2 fields will work: first a shorter name foo_bar_baz_qux_qwert OR a shorter value fooba in the second example

shorter name:

<label class="col-sm-2 col-form-label" for="foo_bar_baz_qux_qwert">Sale Price</label>
<div class="col-sm-4">
  <select name="foo_bar_baz_qux_qwert" id="foo_bar_baz_qux_qwert" class="form-control m-b">
    <option value="foobar">foobar</option>
  </select>
</div>

shorter value:

<label class="col-sm-2 col-form-label" for="foo_bar_baz_qux_qwerty">Sale Price</label>
<div class="col-sm-4">
  <select name="foo_bar_baz_qux_qwerty" id="foo_bar_baz_qux_qwerty" class="form-control m-b">
    <option value="fooba">foobar</option>
  </select>
</div>

So now I think I have some kind hard limit on the total size for all names + values.

I guess I will split this form up into tabs so theres only 10-20 fields per tab, but is anyone aware of such a limit with the validation object?

0 likes
1 reply
Amaury's avatar
Amaury
Best Answer
Level 43

Cookie max size: 4096 bytes… (per domain)

1 like

Please or to participate in this conversation.