Dear all, I have a problem with InfoList and RepeatableEntry. Here the code
[...] public function exhibitionInfolist(Infolist $infolist): Infolist { return $infolist ->record($this->winery) ->schema([ RepeatableEntry::make('exhibitions') ->schema([ InfoLists\Components\TextEntry::make('country') ->formatStateUsing(fn(string $state): HtmlString => new HtmlString( "<div class='w-full fi-header-heading text-xl text-primary-600' >" . $state . "</div>" )) ->suffixAction( Action::make('openMasterclass') ->modalHeading('Select Wine For Masterclass') ->label(function (Exhibition $ex) { return $ex->name; }) ->button() ->form([ Forms\Components\Select::make('wine_id') // ->options(fn () => Wine::all()->pluck('name', 'id')) ->options(function (Exhibition $exhibition) { // here I got the error, becouse is not Exhibition but Winery return $exhibition->wines()->pluck('name', 'wine_id'); }) ]) ->hidden(fn(Exhibition $record): bool => !$record->isWineryinMasterclass($this->winery->id)) ->action(function (array $data, $record): void { $record->updateWineInMasterclass($data['wine_id'], $this->winery); }) )
[...] public function exhibitionInfolist(Infolist $infolist): Infolist { return $infolist ->record($this->winery) ->schema([ RepeatableEntry::make('exhibitions') ->schema([ InfoLists\Components\TextEntry::make('country') ->formatStateUsing(fn(string $state): HtmlString => new HtmlString( "<div class='w-full fi-header-heading text-xl text-primary-600' >" . $state . "</div>" )) ->suffixAction( Action::make('openMasterclass') ->modalHeading('Select Wine For Masterclass') ->label(function (Exhibition $ex) { return $ex->name; }) ->button() ->form([ Forms\Components\Select::make('wine_id') // ->options(fn () => Wine::all()->pluck('name', 'id')) ->options(function (Exhibition $exhibition) { // here I got the error, becouse is not Exhibition but Winery return $exhibition->wines()->pluck('name', 'wine_id'); }) ]) ->hidden(fn(Exhibition $record): bool => !$record->isWineryinMasterclass($this->winery->id)) ->action(function (array $data, $record): void { $record->updateWineInMasterclass($data['wine_id'], $this->winery); }) )
Inside the RepeatableEntry I can access the current "record" belonging to the relationship as it should be. The problem is inside the form element: here if I'm trying to access to the current record I got the record outside the RepeatableEntry (in this case $this->winery). How can I access to the "inner" record? Because my SELECT options depend on it. The "options" are changing for every different Exhibition. Thank you
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community