MutateBeforeSave with Standalone Forms, model(), and statePath()

I am doing something like
public function form(Form $form): Form
{
    return $form
        ->schema([
            Checkbox::make('managed')
                ->reactive()
                ->afterStateUpdated(function (Set $set, $state) {
                    if ($state === false) {
                        $set('housing_locator', []);
                        $set('intermediaryContacts', []);
                    }
                }),
            Select::make('housing_locator')
                ->visible(fn($get) => $get('managed'))
                ->relationship('housingLocators', 'name')
                ->reactive()
                ->afterStateUpdated(function($set) {
                    // set contacts in repeater)
                }),
            Repeater::make('intermediaryContacts')
  ->relationship('intermediaryContacts'),
        ])
        ->statePath('data')
        ->model($this->property ?? Property::class);
}
So everything is just saving directly through the model. Its working fine for adding information, but I am having an issue emptying the select and repeater when the managed field is changed back to false. Don't think simply setting them to an empty array will delete those relational entries. Thoughts?
Was this page helpful?