How to access form component record in ->when fn?
with this code:
i get:
the error line is this one:
the objective is to show hints "A" or hints "B" depending if the
Forms\Components\DateTimePicker::make('paid_at')
->label(__('Paid at'))
->disabled()
->when(
value: function (Forms\Components\DateTimePicker $dateTimePicker, Payment $record): bool {
return $record->has_users;
},
callback: function (Forms\Components\DateTimePicker $dateTimePicker): Forms\Components\DateTimePicker {
return $dateTimePicker
->hint(function (Payment $record): ?string {
if (is_null($record->paid_by_id)) {
return null;
}
return "{$record->paid_at->diffForHumans()}";
})
->hintIcon('heroicon-s-question-mark-circle')
->hintIconTooltip(function (Payment $record): ?string {
if (is_null($record->paid_by_id)) {
return null;
}
return __('Paid by') . " {$record->paidBy->getFullname()} ({$record->paidBy->email}), {$record->paid_at->diffForHumans()}";
})
;
},
default: function (Forms\Components\DateTimePicker $dateTimePicker): Forms\Components\DateTimePicker {
return $dateTimePicker
->hint('false') // ⚠️ todo
;
}
)
,Forms\Components\DateTimePicker::make('paid_at')
->label(__('Paid at'))
->disabled()
->when(
value: function (Forms\Components\DateTimePicker $dateTimePicker, Payment $record): bool {
return $record->has_users;
},
callback: function (Forms\Components\DateTimePicker $dateTimePicker): Forms\Components\DateTimePicker {
return $dateTimePicker
->hint(function (Payment $record): ?string {
if (is_null($record->paid_by_id)) {
return null;
}
return "{$record->paid_at->diffForHumans()}";
})
->hintIcon('heroicon-s-question-mark-circle')
->hintIconTooltip(function (Payment $record): ?string {
if (is_null($record->paid_by_id)) {
return null;
}
return __('Paid by') . " {$record->paidBy->getFullname()} ({$record->paidBy->email}), {$record->paid_at->diffForHumans()}";
})
;
},
default: function (Forms\Components\DateTimePicker $dateTimePicker): Forms\Components\DateTimePicker {
return $dateTimePicker
->hint('false') // ⚠️ todo
;
}
)
,i get:
Too few arguments to function App\Filament\Resources\PaymentResource::App\Filament\Resources\{closure}(), 1 passed in /Users/eric/Documents/projects/suite_bg_wrapper/bgpay/vendor/laravel/framework/src/Illuminate/Conditionable/Traits/Conditionable.php on line 23 and exactly 2 expectedToo few arguments to function App\Filament\Resources\PaymentResource::App\Filament\Resources\{closure}(), 1 passed in /Users/eric/Documents/projects/suite_bg_wrapper/bgpay/vendor/laravel/framework/src/Illuminate/Conditionable/Traits/Conditionable.php on line 23 and exactly 2 expectedthe error line is this one:
value: function (Forms\Components\DateTimePicker $dateTimePicker, Payment $record): bool {value: function (Forms\Components\DateTimePicker $dateTimePicker, Payment $record): bool {the objective is to show hints "A" or hints "B" depending if the
has_usershas_users record field is true or not