#Infolist is the same for all the records.

6 messages · Page 1 of 1 (latest)

spring lark
#

I'm trying to list courses in sections (instead of a table). But for every course it returns the same data (data of the last course) in the infolist. The header and the description of the course are displayed correctly.

public function content(Schema $schema): Schema
    {
        return $schema
            ->columns([
                'default' => 3,
            ])
            ->components($this->getTableRecords()->sortBy('start_at')->map(function ($course) use ($schema) {

                $infolist = CourseResource::infolist($schema)->record($course)->getFlatComponents(withAbsoluteKeys: true);

                unset($infolist['name']);
                unset($infolist['description']);
                unset($infolist['start_enrollment_at']);
                unset($infolist['end_enrollment_at']);

                return Section::make($course->name)
                    ->model($course)
                    ->description($course->description)
                    ->schema([
                        ...$infolist,
                        Action::make('view')
                            ->label('Bekijk cursus')
                            ->url(fn () => ViewCourse::getUrl(['record' => $course]))
                            ->button(),
                ]);
            })->toArray());
    }
scarlet crest
#

I have the same problem

spring lark
#

Seems like I fixed it by adding ->state(fn ($record) => $record->the_attribute_name))to all the components in the infolist.

solid perchBOT
scarlet crest
#

When I try to dump the selected record inside a table action using dd($record), it always returns the first record of the table — no matter which record I actually click on.

golden heath
#

Doesn't look like a bug. You need to set the state somehow