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 Harrin7mo ago
please share code
Bagus A
Bagus AOP7mo ago
I would like to format the date on this select
No description
toeknee
toeknee7mo 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 Harrin7mo ago
getOptionLabelFromRecordUsing()
Want results from more Discord servers?
Add your server