Custom table action for related resources

I have missions and goals components. In the missions component, I created a "Create Goal" table action which renders a modal to add a goal for that mission. When I click submit, it wants to add the record to the missions table, not the goals table. Here's my action code. How do I get it to save to the goals table, also, how do I pass the mission_id to this action?
protected function getTableActions(): array
{
return [
CreateAction::make('Create Goal')
->form(function (Goal $goal) use ($user) {
$form = Form::make('createGoal', [
'model' => $goal,
]);
$form->schema([
Hidden::make('mission_id')
->default(mission_id value???)
....
protected function getTableActions(): array
{
return [
CreateAction::make('Create Goal')
->form(function (Goal $goal) use ($user) {
$form = Form::make('createGoal', [
'model' => $goal,
]);
$form->schema([
Hidden::make('mission_id')
->default(mission_id value???)
....
3 Replies
Dan Harrin
Dan Harrin2y ago
maybe just create your own Action instead of CreateAction
usmcgator
usmcgatorOP2y ago
if I change it from CreateAction to just Action, nothing happens when I click on the action.
Dan Harrin
Dan Harrin2y ago
you have to define your own action() function
Want results from more Discord servers?
Add your server