F
Filament15mo ago
sm

Adding an action to a repeater.

Hey there, I have a repeater that's displaying images using a Placeholder.. I'd like to allow users to select an image from the repeater, but: Placeholder's don't accept suffix actions if I just use Actions::make([]) inside the repeater schema, the actions are all the same action (i.e, triggering one triggers them all) since they're attached to the form. What's the right way to add an action to a repeater so its displayed alongside its items?
2 Replies
sm
smOP15mo ago
Also tried just switching to a grid.. but same question, how can we add an action to non-affix-actionable elements? Code:
return $form
->schema([
Grid::make(4)->schema(function ($record) {
$images = [];
foreach ($record->image_options as $option) {
$images[] = Group::make()->schema([
Placeholder::make('url')
->content(
new HtmlString("<img src=\"{$option['url']}\" style=\"width: 250px; height: auto;\">")
)->hiddenLabel(),

]);
}

return $images;
}),
]);
return $form
->schema([
Grid::make(4)->schema(function ($record) {
$images = [];
foreach ($record->image_options as $option) {
$images[] = Group::make()->schema([
Placeholder::make('url')
->content(
new HtmlString("<img src=\"{$option['url']}\" style=\"width: 250px; height: auto;\">")
)->hiddenLabel(),

]);
}

return $images;
}),
]);
Bump?
LeandroFerreira
LeandroFerreira15mo ago
i.e, triggering one triggers them all different names? What code did you try?
Want results from more Discord servers?
Add your server