F
Filamentβ€’9mo ago
JonathanH-UK

How to prevent releationship creation on Fieldset when field _inside_ the Fieldset is empty

I've found an example from "How do I make a relationship optional?" posted by @TheCrazyBob which uses ->saveRelationshipsUsing($record,$state) however in this case it's making the condition on some other field on the main form whereas I want to only create this relationship if a field inside the FieldSet has been filled. At the moment $record only contains the parent record's fields. Is there a way I can do this based on the Form input instead please?
1 Reply
JonathanH-UK
JonathanH-UKβ€’9mo ago
I've answered my own question on this πŸ˜† It's really simple - I ignore $record and look at whether $state is null and if not whether the field I care about is set.