How to get the right statePath?
I have a form with a statePath:
On output, the $data is shaped like this:
What I want is to require
field2
when field1
is > 0
I tried that (based on other answers in this discord) but I think I'm not giving the right state path:
14 Replies
$get(‘group.field1’)
Or $get(‘./field1’)
It follows directory path syntax.
no no no, the $get is working fine with
$get('field1')
. That's the return value that is wrong:
Let me choose a more clear example:
try expenses.amount. We array map the statePath so it is possible it's getting the current path which would be expenses.amount. I haven't tested it though.
whoops, I just tested my exemple and it actually works...
haha funny, we do use state paths but it should get the current path lol.
My real form is pretty huge, so I wanted to give a simple exemple. Give me one minute
Ok, that's because of the FileUpload:
Ahh ok, so it's actually FileUpload that's not working with requiredWith
yes, sorry
Can you submit a bug report in that scenario plesae with a repoduction repo?
But it's not because of statePath
Correct, it's the field not working with it. Likely because file uploads are handled differently
There's already an existing bug here: https://github.com/filamentphp/filament/issues/15954
GitHub
requiredIf not working with FileUpload component · Issue #15954 ·...
Package filament/filament Package Version v3.3.3 Laravel Version v12.1.1 Livewire Version v3.6.1 PHP Version PHP 8.4.5 Problem description In a form with a select with two options and two dependent...
That's with
requiredIf
, not requiredWith
, but I think these issues are linked
Also a discord thread in this channel: https://discord.com/channels/883083792112300104/1141465962483286057Yep please comment on it too