Adding unique names to Actions within a RepeatableEntry

Hi Everyone, Here's a trimmed down version of the code I'm trying:
Section::make('components')
->columns(8)
->heading('Environments')
->schema([
RepeatableEntry::make('environments')
->label("")
->schema([
Section::make('environment')
->heading(fn (Environment $record): string => $record->domain)
->label("")
->columns(8)
->schema([Actions::make([
Action::make('create-repo')
->label("Create new Repo")
->visible(fn (Environment $record): bool => $record->repository()->doesntExist())
->form(fn (Form $form): Form => RepositoryResource::form($form) )
->size(ActionSize::ExtraSmall)
->action(function (array $data, Environment $record) {
return $record->repository()->create($data);
}),
])
])
])
]);
Section::make('components')
->columns(8)
->heading('Environments')
->schema([
RepeatableEntry::make('environments')
->label("")
->schema([
Section::make('environment')
->heading(fn (Environment $record): string => $record->domain)
->label("")
->columns(8)
->schema([Actions::make([
Action::make('create-repo')
->label("Create new Repo")
->visible(fn (Environment $record): bool => $record->repository()->doesntExist())
->form(fn (Form $form): Form => RepositoryResource::form($form) )
->size(ActionSize::ExtraSmall)
->action(function (array $data, Environment $record) {
return $record->repository()->create($data);
}),
])
])
])
]);
The issue arises with having multiple action buttons all named "create-repo". Here are the things I've tried: * Adding a closure to make() - the method does not accept closures. * Creating some kind of random string - the buttons stop working completely, I think because every time it loads the button, it's getting a different name for it. * Accessing some version of $infolist or $record - they are not in scope unless injected into a closure. So basically, I'm stuck. Action buttons need a unique name, but I can't for the life of me figure out how to give them one. Am I pushing InfoLists WAY past what they are supposed to do, and should I be making a custom page / dashboard full of widgets?
3 Replies
Malcolm Turntbull
Malcolm TurntbullOP14mo ago
bump! anyone else run into issues giving Actions unique names, and have a solution they used?
awcodes
awcodes14mo ago
Still trying to figure this out. It’s not necessarily a naming thing. But a scoping issue. There’s a few issues on GitHub about it. But we are working on it.
Malcolm Turntbull
Malcolm TurntbullOP14mo ago
Thanks for the feedback - for now I'll focus on building out the functionality on separate View pages, and later on I can start integrating it back into a single pane of glass. Cheers!
Want results from more Discord servers?
Add your server