mutateRelationshipDataBeforeFillUsing

How to show date in d/m/Y format without datepicker coming from a relationship? DatePicker solves the formatting, but users with visual difficulties find it difficult to use the picker, that's why they don't want to use the datepicker, I tried using mutateRelationshipDataBeforeFillUsing but it doesn't work for relationship, mutateRelationshipDataBeforeSaveUsing works for saving, but mutateRelationshipDataBeforeFillUsing doesn't for filling
No description
No description
2 Replies
PegeDev
PegeDev2mo ago
any update for this issue ?
LeandroFerreira
LeandroFerreira2mo ago
old post, but you can use
$data['dt_nascimento'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['dt_nascimento'])->format('d/m/Y');
$data['dt_nascimento'] = Carbon::createFromFormat('Y-m-d H:i:s', $data['dt_nascimento'])->format('d/m/Y');
You can also use formatStateUsing in the field
TextInput::make('dt_nascimento')
->formatStateUsing(fn (?string $state) => Carbon::createFromFormat('Y-m-d H:i:s', $state)->format('d/m/Y'))
TextInput::make('dt_nascimento')
->formatStateUsing(fn (?string $state) => Carbon::createFromFormat('Y-m-d H:i:s', $state)->format('d/m/Y'))
Want results from more Discord servers?
Add your server