FilamentF
Filament13mo ago
Carlos

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'),
`

And in my model I have this relationship:

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
Was this page helpful?