filament
filament copied to clipboard
Add pivot attributes to Select and CheckboxList components
Its common to have pivot attributes on pivot tables. Currently there's no support to filling those properties when saving a Select or CheckboxList field.
The ->pivotAttributes() method
If you're using a BelongsToMany relationship and your pivot table has additional columns, you can use the pivotAttributes() method to specify the pivot attributes that should be saved:
use Filament\Forms\Components\Select;
Select::make('technologies')
->relationship(titleAttribute: 'name')
->pivotAttributes([
'is_primary' => true,
])
Just stumbled across this again, and i think this should be ->mutateRelationshipDataBeforeXUsing()?