CheckboxList inside a Fieldset not saving relationship
I have a checkboxlist in a second fieldset. I get all the options from the ->relationship() but when i save the mode, the relationships do not save in the pivot table.
My model has the many to many relationship defined.
public static function getForm(): array
{
return [
Fieldset::make('Asset Information')
->schema([
Select::make('client_id')
->label('Client')
->relationship('client', 'name')
->columnSpanFull()
->searchable()
->preload()
->required(),
TextInput::make('name')
->label('Asset Name')
->required(),
]),
Fieldset::make('Asset Watchers')
->visible(fn ($record) => is_null($record))
->schema([
CheckboxList::make('users')
->label('Team members')
->relationship('users', 'name')
->bulkToggleable()
->columnSpanFull()
->searchable()
->required()
->columns(3)
->gridDirection('row')
->hint('Team members that will be notified near expiration')
->searchPrompt('Search for a team member'),
]),
];
}
public static function getForm(): array
{
return [
Fieldset::make('Asset Information')
->schema([
Select::make('client_id')
->label('Client')
->relationship('client', 'name')
->columnSpanFull()
->searchable()
->preload()
->required(),
TextInput::make('name')
->label('Asset Name')
->required(),
]),
Fieldset::make('Asset Watchers')
->visible(fn ($record) => is_null($record))
->schema([
CheckboxList::make('users')
->label('Team members')
->relationship('users', 'name')
->bulkToggleable()
->columnSpanFull()
->searchable()
->required()
->columns(3)
->gridDirection('row')
->hint('Team members that will be notified near expiration')
->searchPrompt('Search for a team member'),
]),
];
}
0 Replies