F
Filament5mo ago
Kitty

Repeater Relationship missing :condition

What I am trying to do: Not Create Empty Repeater Relationships What I Tried: Using the :condition variable. HasOne components have a :condition variable on the ->relationship method that allows you to set the field as optional so that the form does not try to create the relationship with an empty value. But it seems the HasMany Repeater does not support this variable. What I would like help with: Q: Is this to be expected? Q2: How can I make a repeater be optional? Note: I would prefer to set default to 1 and not create empty relationships.
Example: Works Forms\Components\Group::make() ->relationship( 'childFamilyIncome', condition: fn (?array $state): bool => filled($state['family_income_id']), ) ->schema([ ... ]) Example: Doesn't work. Error Unknown named parameter $condition Forms\Components\Repeater::make('childEthnicities') ->relationship('childEthnicities', condition: fn (?array $state): bool => filled($state['ethnicity_id'])) ->label('Child Ethnicities') ->simple( ... ) ->defaultItems(1)
1 Reply
Kitty
Kitty5mo ago
What I am Trying to Do: Not create empty repeater relationships.