FilamentF
Filament2y ago
Xavi

TagsInput belongsToMany

How can i set the TagsInput value on edit form, if values are a belongsToMany relationship

i try something like this, but it doesn't works


->loadStateFromRelationshipsUsing(function ($record) {
    return $record->keywords()->where('manual', true)->pluck('name')->toArray();
})


Thanks
Solution
i found solution with

->mutateRecordDataUsing(function (array $data, $record): array {
    $data['keywords'] = $record->keywords()->where('manual', true)->pluck('name')->toArray();
    return $data;
})

on EditAction.

Thanks!
Was this page helpful?