FilamentF
Filament3y ago
2 replies
core

AttachAction :use the same modal form for the Edit action in a relationsmanager

My IngredientsRelationManager is working attaching records to the pivot table recipe_ingredient,
but the edit action returns a different form in the Modal, (no select "units" dropdown and on edit then the ingredient name is returned as the ingredient_id, in the IngredientsRelationManager table for some reason.

what do I need to config?
full file gist:
https://gist.github.com/dflow/3f3b24109bf08ffad3ab27770e0bc8f0
 ->headerActions([
                // ...
                AttachAction::make()
                    ->modalHeading('Add Ingredient')
                    ->modalDescription('Add ingredients, quantities and units')
                    ->modalSubmitActionLabel('Add')
                    ->attachAnother(false)
                    ->preloadRecordSelect()
                    ->label('Add Ingredient')
                    ->form(fn (AttachAction $action): array => [
                        $action->getRecordSelect(),
                        Forms\Components\TextInput::make('quantity')->required(),
                        Select::make('unit')
                            ->label('Unit')
                            ->options(Unit::query()->pluck('unit', 'symbol'))
                            ->required(),
                    ]),

            ])
            ->actions([
                // ...
                Tables\Actions\EditAction::make(),
                Tables\Actions\DetachAction::make()
                    ->modalHeading('Remove Ingredient')
                    ->modalIcon('heroicon-o-trash')
                    ->label('Remove'),

            ])
Gist
AttachAction: use the same modal form for the Edit action in a relationsmanager - gist:3f3b24109bf08ffad3ab27770e0bc8f0
AttachAction: use the same modal form for the Edit action in a rela...
Was this page helpful?