F
Filament2mo ago
lbar

DatePicker problem accessing the field from the relationship

I'm struggling with this specific problem on DatePicker, so as last resort i'm trying to write there. Basically I have a birth_date (type date) field on the sql. I'm accessing this field on two different resource. The first one is the resource itself of the table, and works correctly:
Forms\Components\DatePicker::make('birth_date')
->translateLabel()
->required(),
Forms\Components\DatePicker::make('birth_date')
->translateLabel()
->required(),
the DatePicker is correctly populated with the date that I have on the database. The second one give the problems:
Grid::make()
->relationship('mainMember')
->schema([
[...]
Forms\Components\DatePicker::make('birth_date')
->translateLabel()
->required(),
Grid::make()
->relationship('mainMember')
->schema([
[...]
Forms\Components\DatePicker::make('birth_date')
->translateLabel()
->required(),
The relation on the model is that one:
public function mainMember(): HasOne
{
return $this->hasOne(Member::class)->where('is_main', 1);
}
public function mainMember(): HasOne
{
return $this->hasOne(Member::class)->where('is_main', 1);
}
If I compare the date on both field (working/no-working, dumping the value on formatStateUsing) i have the exaclty date:
working -> 2020-12-25T00:00:00.000000Z
no working -> 2020-12-25T00:00:00.000000Z
working -> 2020-12-25T00:00:00.000000Z
no working -> 2020-12-25T00:00:00.000000Z
There is some hero that can understand what I wrong? ty
Solution:
solved with this casting on the model: 'birth_date' => 'date:Y-m-d' no idea why i needed to explicit the casting format, otherwise from the relations the picker can't grab the correct one....
Jump to solution
1 Reply
Solution
lbar
lbar2mo ago
solved with this casting on the model: 'birth_date' => 'date:Y-m-d' no idea why i needed to explicit the casting format, otherwise from the relations the picker can't grab the correct one.
Want results from more Discord servers?
Add your server