F
Filament16mo ago
hacxper

Get repeated record inside RepeatableEntry

Hi, I'm using infolist for my View page. I'm using RepeatableEntry to list my hasMany relationship. Inside the repeater, I might need to access repeated model. For actions, generating urls etc. how can I get current repeated model?
6 Replies
toeknee
toeknee16mo ago
Can you provide your code please.
hacxper
hacxperOP16mo ago
sure,
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
/* ... some fields */
RepeatableEntry::make('products')
->schema([
TextEntry::make('orderStatus.title')
->badge(),
Actions::make([
Action::make('updateProduct')
->requiresConfirmation()
->form([
TextInput::make('order_link')
->required(), /* I want to get product.order_link here where product is the current repeated record */
])
->size(ActionSize::ExtraSmall)
->action(function (array $data) {
/* want to save product's order_link here */
return;
}),
/* ... some more actions */

]),
]),
]);
}
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
/* ... some fields */
RepeatableEntry::make('products')
->schema([
TextEntry::make('orderStatus.title')
->badge(),
Actions::make([
Action::make('updateProduct')
->requiresConfirmation()
->form([
TextInput::make('order_link')
->required(), /* I want to get product.order_link here where product is the current repeated record */
])
->size(ActionSize::ExtraSmall)
->action(function (array $data) {
/* want to save product's order_link here */
return;
}),
/* ... some more actions */

]),
]),
]);
}
I might use fillForm() for actions, but I'm not sure how can I get the proper data
toeknee
toeknee16mo ago
I am not 100% on that use tbh, but usually you use $record within actions, for that records data
hacxper
hacxperOP16mo ago
$record returns top level model, not related model.
toeknee
toeknee16mo ago
I think you need to groupm the content with a group or card, and set a relationship within that card to load those details
hacxper
hacxperOP16mo ago
can you provide me some code? If I can load data through my model, it would be possible.
Want results from more Discord servers?
Add your server