Make hidden repeater

When creating a form, I should display only one repeater, depending on the type field in the same form, after which I use ->visible(fn($record) => $record-> === 'value'), but on the final page, when changing the type to select repeater, it changes only after updating the page
4 Replies
LeandroFerreira
LeandroFerreira2mo ago
difficult for anyone to assist without any code or a clear context..
sharinganglow
sharinganglow2mo ago
Select::make('type') ->options(Types::getAllTypes()) ->live() ->label('Type'), Repeater::make('first') ->schema([...]) ->relationship() ->collapsed() ->collapsible() ->reorderable() ->addActionLabel('Add First Type') ->label('First Type') ->cloneable() ->visible(fn($record) => $record->type === 'first') ->itemLabel(fn(array $state): ?string => $state['name'] ?? null); Repeater::make('second') ->schema([...]) ->relationship() ->collapsed() ->collapsible() ->reorderable() ->addActionLabel('Add Second Type') ->label('Second Type') ->visible(fn($record) => $record->type === 'second') ->itemLabel(fn(array $state): ?string => $state['name'] ?? null);
LeandroFerreira
LeandroFerreira2mo ago
When creating a form... $record there isn't record in the create page, at this point I guess You should inject Get $get and use $get('type')
sharinganglow
sharinganglow2mo ago
yes, work for me, thank you!
Want results from more Discord servers?
Add your server