F
Filament2y 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
smOP2y 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
i.e, triggering one triggers them all different names? What code did you try?

Did you find this page helpful?