Closure Validation: Get $get doesn't resolve correctly
I've got a form where I need to validate that part of an input matches a date input. From the docs (https://filamentphp.com/docs/3.x/forms/validation#custom-rules) I should be able to resolve
Get $get
in a function and then return my closure rule using it. However, $get
's value only contains the field I'm validating, not the entire form state.
Thus, any calls to $get('value')
return null.
Screenshots attached showing the value of $get
and the code.6 Replies
Could you dump
$get('*')
and $get('../*')
?
I think array $state
could also do the thing instead of Get $get
.Interesting, didn't know
$get
was "traversable". It seems the keys lack their field keys as the key and are just using an index. Sreenshot is $get(*)
.Reuploading the code screenshot since the initial screenshot was a debug version instead of the real one
as for
array $state
, I don't think that'll work, it errors saying it expects array but gets null instead. IIRC $state only gives the current field value no?Try
../../*
π
that should add keysNope,
../*
and ../../*
return null.
I've decided it was simpler to refactor the UI ordering so that this field is auto-filled from the other value instead of doing this rule - saves a bit of user input. But still felt it's worth posting this in case anyone else runs into the issue.