FilamentF
Filament12mo ago
grardb

Dynamic `required()`/`visible()` within a Repeater

I've got a Form with Select:
return $form
    ->schema([
        Select::make('event_id')
            ->searchable(['event_locations.name'])
            ->live()
            ->relationship(...)
            ->preload()
            ->getOptionLabelFromRecordUsing(...),

The Event model has certain attributes which inform the requirements of the form, e.g. $event->is_food_provided.

Within a Fieldset, updating the visibility of a
TextInput
works:
Fieldset::make('Participant info')
    ->schema([
        ...
        TextInput::make('dietary_requirements')
            ->visible(fn (Get $get) => Event::find($get('event_id'))?->is_food_provided),

However, this does not seem to work when it's inside a Repeater:
Repeater::make('participants')
    ->schema([
        ...
        TextInput::make('dietary_requirements')
            ->visible(fn (Get $get) => Event::find($get('event_id'))?->is_food_provided),
    ]),

For the Repeater, the visible() check gets executed and is respected on page load, but not when the Select/Event is changed.

Is this expected behavior, am I doing something wrong, or is this a bug? I couldn't find anything in the documentation or GitHub issues about this.
Was this page helpful?