filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.

Home Page:https://filamentphp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table $record not passing to repeater with relationship on EditAction

krutsednar opened this issue · comments

Package

filament/filament

Package Version

v3.0.0

Laravel Version

v10

Livewire Version

v3

PHP Version

PHP 8.2

Problem description

Appointment Table with EditAction not passing data to repeater

Expected behavior

Age should be automatically calculated based on birthday in table row

Steps to reproduce

EditAction::make()
                    ->label('')
                    ->modalWidth(MaxWidth::SevenExtraLarge)
                    ->color('info')
                    ->form([
                        Wizard::make([
                            Wizard\Step::make('checkup')
                                ->icon('heroicon-s-document-plus')
                                ->columns([
                                    'sm' => 3,
                                    'xl' => 6,
                                    '2xl' => 8,
                                ])
                                ->schema([
                                    Section::make()

                                        ->columns([
                                            'sm' => 3,
                                            'xl' => 6,
                                            '2xl' => 8,
                                        ])
                                        ->schema([
                                            TextInput::make('ref_no')
                                                ->columnSpan([
                                                    'sm' => 2,
                                                ])
                                                ->readOnly(),
                                            TextInput::make('queue_number')
                                                ->columnSpan([
                                                    'sm' => 2,
                                                ])
                                                ->readOnly(),
                                            TextInput::make('patient_name')
                                                ->columnSpan([
                                                    'sm' => 2,
                                                ])
                                                ->readOnly()
                                                ->formatStateUsing(function ($record) {
                                                    if ($record && $record->childName) {
                                                        return $record->childName->first_name . ' ' . $record->childName->middle_name . ' ' . $record->childName->last_name;
                                                    } else {
                                                        return '-';
                                                    }
                                                }),
                                            TextInput::make('age')
                                                ->columnSpan([
                                                    'sm' => 2,
                                                ])
                                                ->readOnly()
                                                ->formatStateUsing(function ($record) {
                                                    if ($record) {
                                                        return Carbon::parse(BasicInformation::where('id', $record->value('child_name_id'))->value('birthday'))->diff(Carbon::now())->format('%y years, %m months and %d days');
                                                    } else {
                                                        return '-';
                                                    }
                                                }),
                                        ]),
                                    Section::make()
                                        ->columns(1)
                                        ->schema([
                                            Repeater::make('checkupRecords')
                                                ->relationship('checkupRecords')
                   
                                                ->schema([
                                                    DatePicker::make('date')
                                                        ->afterStateHydrated(function (DatePicker $component, ?string $state) {
                                                            // if the value is empty in the database, set a default value, if not, just continue with the default component hydration
                                                            if (!$state) {
                                                                $component->state(now()->toDateString());
                                                            }
                                                        }),
                                                    TextInput::make('age')
                                                        ->formatStateUsing(function ($record) {
                                                             if ($record) {
                                                                return Carbon::parse(BasicInformation::where('id', $record->value('child_name_id'))->value('birthday'))->diff(Carbon::now())->format('%y years, %m months and %d days');
                                                            } else {
                                                                 return '-';
                                                             }
                                                        })
                                                         ->columnSpan([
                                                             'sm' => 1,
                                                         ])
                                                         ->readOnly(),
                                                
                                        ]),



                                ]),

                    ]),

Reproduction repository

https://github.com/krutsednar/klinikids

Relevant log output

No response

Donate 💰 to fund this issue

  • You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
  • 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
  • Thank you in advance for helping us make maintenance sustainable!
Fund with Polar

No simple reproduction repository, current one 404s. Please start a new app from scratch to share.