Best practice for handling optional many-to-many relationships with conditional fields in Filament P

Hello Filament community! I'm working on a project where I have a many-to-many relationship between Items and Nutritional Information, connected through a pivot table. The nutritional information is optional and depends on an enum in the items table. I'm struggling to set this up properly in Filament. I've tried several approaches, but they all feel like hacks and are causing issues down the line. Here's an example of what I've tried: ```php public static function getNutritionBuilder() { $nutritionInformation = ItemNutritionInformation::all(); return Forms\Components\Tabs\Tab::make('Nutritions') ->schema( $nutritionInformation->map(function ($item) { return Forms\Components\Group::make([ Forms\Components\TextInput::make("nutritional_attributes.{$item->id}.value") ->label($item->name) ->numeric() ->required(), ]); })->toArray() ) ->columns(2); } What is a proper way to set this one up nicely in filament? Thanks in advance!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server