© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
JL

Add value to field in pivot table in CreateAction

Hello I have this code in v2

return $table
->columns(CategoryResource::getTableFields())
->filters([])
->headerActions([
Tables\Actions\CreateAction::make()
->using(function (HasRelationshipTable $livewire, array $data): Model {
$parentCategory = $livewire->getRelationship()->getParent();
$dataPivot['pivotorder'] = $parentCategory->subcategories()->max('pivotorder') + 1;
return $livewire->getRelationship()->create($data,$dataPivot);
}),


this code worked.

In v3


return $table
->recordTitleAttribute('name')
->columns(CategoryResource::getTableFields())
->filters([])
->headerActions([
CreateAction::make()
->using(function (array $data, string $model): Model {
return $model::create($data);
})
])

first, in headersActions never enters. but in emptyStateActions, it does.

second, how i can get the relationship for get the parent category?

thx
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Insert data to a pivot table in table CreateAction?
FilamentFFilament / ❓┊help
2y ago
Form field in relationship to pivot table
FilamentFFilament / ❓┊help
3y ago
Display value of Pivot Table
FilamentFFilament / ❓┊help
3y ago