F
Filament7mo ago
Pan

How to create a form to Edit record instead of Create in RelationManager excluding AssociateAction

I have a relation manager in my userResource and I tried AssociateAction and it works however I need to be able to customize so I thought of creating a custom Action but when I create a form schema for it. But when I simply save it, it just creates a new record. I want to instead update the equipment field foreign id for user_id to what user edit record page I am currently at. I also want it to be multiple() so I don't have to do it one by one
Tables\Actions\AssociateAction::make(),
Tables\Actions\Action::make('Borrow')
->form([
Forms\Components\Select::make('barcode')
->searchable()
->multiple()
///where('barcode') is what is searched and pluck('name') is what appears
->getSearchResultsUsing(fn (string $search): array => Equipment::where('barcode', 'like', "%{$search}%")->limit(50)->pluck('name')->toArray())
]),
Tables\Actions\AssociateAction::make(),
Tables\Actions\Action::make('Borrow')
->form([
Forms\Components\Select::make('barcode')
->searchable()
->multiple()
///where('barcode') is what is searched and pluck('name') is what appears
->getSearchResultsUsing(fn (string $search): array => Equipment::where('barcode', 'like', "%{$search}%")->limit(50)->pluck('name')->toArray())
]),
1 Reply