statamic-livewire-forms icon indicating copy to clipboard operation
statamic-livewire-forms copied to clipboard

500 when submitting form

Open Krzemo opened this issue 7 months ago • 6 comments

Submitting a form throws: Undefined array key "first_name" (fails on first field) Also when wire_model: live.debounce.150ms is set for a field in BP - same error when fields looses focus (validation related?).

Rootcause(?): It looks like $this->submittableFields in vendor/aerni/livewire-forms/src/Livewire/Concerns/HandlesValidation.php:23 is empty.

After some digging it looks like for some reason with my setupdist/js/forms.js fails to set it (or even to add to Alpine data?) There are no errors in console. Form is standard one generate by livewire-forms:setup

Interestingly when I did ugly workaround by changing:

  1. src/Livewire/Concerns/HandlesValidation.php:22 ->filter(fn ($value, $field) => $this->submittableFields[$field] ?? true)

  2. src/Livewire/Concerns/HandlesValues.php:21 ->filter(fn ($field) => $this->submittableFields[$field->handle] ?? true)

Everything works perfectly fine.

Environment
Application Name: Statamic
Laravel Version: 11.44.2
PHP Version: 8.3.16
Composer Version: 2.8.3
Environment: local
Debug Mode: ENABLED
URL: rapid-lp.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Livewire
Livewire: v3.6.2

Statamic
Addons: 2
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.50.0 PRO

Statamic Addons
aerni/livewire-forms: 9.9.1
marcorieser/statamic-livewire: 4.1.0

Krzemo avatar Mar 15 '25 23:03 Krzemo

I can't reproduce this issue on a fresh installation. There were a couple of changes to the scripts. Try publishing them afresh with php please install. Maybe you still have the old scripts in public/vendor/livewire-forms.

aerni avatar Mar 17 '25 14:03 aerni

Did you get it working?

aerni avatar Mar 21 '25 16:03 aerni

Nope. I forked for now and applied ugly workaround with ?? Its a clean install too so really strange. Do you want me to close it?

Krzemo avatar Mar 24 '25 15:03 Krzemo

This is odd. Can you provide steps to reproduce? It works on my end but I'm probably missing something.

aerni avatar Mar 24 '25 16:03 aerni

Would love to fix this. You say:

After some digging it looks like for some reason with my setup dist/js/forms.js fails to set it (or even to add to Alpine data?).

What's your setup? Anything special? Are you bundling manually by any chance? Can you provide a simple repo that reproduces the issue?

aerni avatar Apr 01 '25 23:04 aerni

Just giving this another nudge 😉

aerni avatar Apr 22 '25 23:04 aerni

Are you still running into this issue?

aerni avatar Jul 03 '25 16:07 aerni

Hey @aerni Im sorry for abandoning this. I cannot replicate that on completly new install and project this issue popped up on has been stalled for some time. Im closing it.

Krzemo avatar Jul 03 '25 17:07 Krzemo