F
Filamentβ€’15mo ago
NikSpyratos

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.
No description
6 Replies
alexanderkroneis
alexanderkroneisβ€’15mo ago
Could you dump $get('*') and $get('../*')? I think array $state could also do the thing instead of Get $get.
NikSpyratos
NikSpyratosOPβ€’15mo ago
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(*).
No description
NikSpyratos
NikSpyratosOPβ€’15mo ago
Reuploading the code screenshot since the initial screenshot was a debug version instead of the real one
No description
NikSpyratos
NikSpyratosOPβ€’15mo ago
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?
alexanderkroneis
alexanderkroneisβ€’15mo ago
Try ../../* πŸ˜… that should add keys
NikSpyratos
NikSpyratosOPβ€’15mo ago
Nope, ../* 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.
Want results from more Discord servers?
Add your server