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);
}
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);
}