CheckboxList not working on Edit

Hello, I have this Checkbox list field that depends of the value of another field:
Forms\Components\CheckboxList::make('countries')
->relationship('countries', 'name')
->visible(fn (Get $get) => $get('applies_to_relationship') === 'countries'),
Forms\Components\CheckboxList::make('countries')
->relationship('countries', 'name')
->visible(fn (Get $get) => $get('applies_to_relationship') === 'countries'),
` And in my model I have this relationship:
public function countries(): BelongsToMany
{
return $this->belongsToMany(Country::class, 'countries_campaigns', 'campaigns_id', 'countries_id');
}
public function countries(): BelongsToMany
{
return $this->belongsToMany(Country::class, 'countries_campaigns', 'campaigns_id', 'countries_id');
}
When I create a resource it works, and saves the related records, but when I try to edit a record it doesn't store the changes and wipes out any previous related record. How can I address this? Thank you
1 Reply
toeknee
toeknee4w ago
Probably because the countries / applies_to_relationship isn't set within the model fillable?
Want results from more Discord servers?
Add your server