F
Filamentβ€’15mo ago
AngryTestie

How to run a function after adding new data using createOptionForm()

I want to inser data in pivot table after new data is save.How can I do that?here is my code . Forms\Components\Select::make('location') ->label('Location') ->multiple() ->relationship('locations','location_name',fn (Builder $query) => $query->where('company_id', Auth::user()->current_company_id)) ->preload() ->createOptionForm([ Forms\Components\TextInput::make('location_name') ->required(), Hidden::make('company_id') ->default( Auth::user()->current_company_id) ]),
4 Replies
Lara Zeus
Lara Zeusβ€’15mo ago
->createOptionAction()
AngryTestie
AngryTestieOPβ€’15mo ago
how can I get the id of that created data?
Lara Zeus
Lara Zeusβ€’15mo ago
sorry its createOptionUsing πŸ™‚
->createOptionUsing(function (array $data) {
//
})
->createOptionUsing(function (array $data) {
//
})
AngryTestie
AngryTestieOPβ€’15mo ago
@Lara Zeus I cant get the id of the newly created location is there other functions that works like with afterCreate()?with that I can get the record->id
Want results from more Discord servers?
Add your server