FilamentF
Filament3y ago
core

EditAction on relationsmanager updating wrong table

I have an IngredientsRelationManager on. RecipeResource.
the AttachAction And Detach work fine updating the recipe_ingredient table .for some reason in the EditAction the following code updates the ingredients table name field with the ingredients.id,
$ingredients = Cache::remember('ingredients_list', 60, function () {
            return Ingredient::all()->pluck('name', 'id')->toArray();
        });
//
->actions([
                // ...
                Tables\Actions\EditAction::make()
                    ->form([
                        Forms\Components\Select::make('name')
                            ->searchable()
                            ->options($ingredients),
                        Forms\Components\TextInput::make('quantity')->required(),
                        Select::make('unit')
                            ->label('Unit')
                            ->options(Unit::query()->pluck('unit', 'symbol'))
                            ->required(),
                    ]),
                Tables\Actions\DetachAction::make()
                    ->modalHeading('Remove Ingredient')
                    ->modalIcon('heroicon-o-trash')
                    ->label('Remove'),

            ])
Was this page helpful?