diff --git a/app/Filament/User/Resources/BatchResource.php b/app/Filament/User/Resources/BatchResource.php index 5358d29..302ca64 100644 --- a/app/Filament/User/Resources/BatchResource.php +++ b/app/Filament/User/Resources/BatchResource.php @@ -132,20 +132,12 @@ class BatchResource extends Resource Forms\Components\Repeater::make('origins') ->label('') ->relationship() - ->afterStateHydrated(function ($component, $record) { - // Pre-fill on create only when no origins exist - if ($record?->id) { - return; - } - // State is set reactively via recipe_id afterStateUpdated - }) ->schema([ - Forms\Components\Hidden::make('spice_id'), - Forms\Components\Placeholder::make('spice_name') + Forms\Components\Select::make('spice_id') ->label('Rohstoff') - ->content(fn (Get $get): string => - Spice::find($get('spice_id'))?->name ?? '—' - ), + ->options(Spice::orderBy('name')->pluck('name', 'id')) + ->searchable() + ->required(), Forms\Components\Select::make('supplier_id') ->label('Lieferant') @@ -168,7 +160,7 @@ class BatchResource extends Resource ->columnSpanFull(), ]) ->columns(2) - ->addActionLabel('Rohstoff hinzufügen') + ->addActionLabel('Eintrag hinzufügen') ->reorderable(false), ]), ]); diff --git a/app/Filament/User/Resources/ProductResource/RelationManagers/BatchesRelationManager.php b/app/Filament/User/Resources/ProductResource/RelationManagers/BatchesRelationManager.php index 1cf5066..7dbe46d 100644 --- a/app/Filament/User/Resources/ProductResource/RelationManagers/BatchesRelationManager.php +++ b/app/Filament/User/Resources/ProductResource/RelationManagers/BatchesRelationManager.php @@ -117,12 +117,11 @@ class BatchesRelationManager extends RelationManager ])->toArray()); }) ->schema([ - Forms\Components\Hidden::make('spice_id'), - Forms\Components\Placeholder::make('spice_name') + Forms\Components\Select::make('spice_id') ->label('Rohstoff') - ->content(fn (Get $get): string => - Spice::find($get('spice_id'))?->name ?? '—' - ), + ->options(Spice::orderBy('name')->pluck('name', 'id')) + ->searchable() + ->required(), Forms\Components\Select::make('supplier_id') ->label('Lieferant') @@ -145,7 +144,7 @@ class BatchesRelationManager extends RelationManager ->columnSpanFull(), ]) ->columns(2) - ->addActionLabel('Rohstoff hinzufügen') + ->addActionLabel('Eintrag hinzufügen') ->columnSpanFull(), ]); }