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 Zeus17mo ago
->createOptionAction()
AngryTestie
AngryTestieOP17mo ago
how can I get the id of that created data?
Lara Zeus
Lara Zeus17mo ago
sorry its createOptionUsing 🙂
->createOptionUsing(function (array $data) {
//
})
->createOptionUsing(function (array $data) {
//
})
AngryTestie
AngryTestieOP17mo 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

Did you find this page helpful?