Using formatStateUsing on Select relationship

How can we, for example format a date with the source coming from a relationship? I've tried using formatStateUsing but it doesn't seem to work.
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('bucket_id')
->relationship(name: 'bucket', titleAttribute: 'date')
->required()
->preload()
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Select::make('bucket_id')
->relationship(name: 'bucket', titleAttribute: 'date')
->required()
->preload()
]);
}
4 Replies
Dan Harrin
Dan Harrin2mo ago
please share code
Bagus A
Bagus A2mo ago
I would like to format the date on this select
No description
toeknee
toeknee2mo ago
Can you share your model, it looks like you are casting to datetime but should be casting to date. Otherwise if you want to custom it, use getOptionLabelFromRecordUsing
Dan Harrin
Dan Harrin2mo ago
getOptionLabelFromRecordUsing()