Spatie translatable relation select return json

i update v2 to v3 and see translatable rows return in select relation as json
No description
18 Replies
Dimitry Solunsky
Dimitry Solunsky16mo ago
I dont know why spatie not return default locale, maybe see config file. but fast solution, TextColumn::make('category.ru').
undefined
undefinedOP16mo ago
it`s not work for me)
Saifallak
Saifallak16mo ago
Do something like this
Forms\Components\Select::make('level_id')
->searchable()
->preload()
->translateLabel()
->required()
->getOptionLabelFromRecordUsing(fn(Model $record) => $record->name)
->relationship('level', 'name'),
Forms\Components\Select::make('level_id')
->searchable()
->preload()
->translateLabel()
->required()
->getOptionLabelFromRecordUsing(fn(Model $record) => $record->name)
->relationship('level', 'name'),
Get option label from record using
Shaung Bhone
Shaung Bhone16mo ago
Is official plugin?
undefined
undefinedOP16mo ago
Yeah, but how possible is unofficial?
Shaung Bhone
Shaung Bhone16mo ago
Yes, I got issue with this package in filament 3 fresh installation.
undefined
undefinedOP16mo ago
you don't have fix this error?
Shaung Bhone
Shaung Bhone16mo ago
Not yet You can use this plugin https://filamentphp.com/plugins/bezhansalleh-language-switch it's good one.
undefined
undefinedOP16mo ago
this plugin is different from spatie and filament realisation and don't fit to me
Shaung Bhone
Shaung Bhone16mo ago
it is base on spatie.
undefined
undefinedOP16mo ago
based on spatie, but not include spatie translate
Shaung Bhone
Shaung Bhone16mo ago
You can open an issues.
mgkyawzayya
mgkyawzayya16mo ago
I don't get any issues and all are working bro
Shaung Bhone
Shaung Bhone16mo ago
So OP need help from you.
paulohenriquesg
paulohenriquesg15mo ago
Hi there! Did you solve this somehow? I'm facing the same issue :\
Majid Al Zariey
Majid Al Zariey15mo ago
Same here
Lara Zeus
Lara Zeus15mo ago
>getOptionLabelFromRecordUsing(fn(Model $record) => $record->name)
>getOptionLabelFromRecordUsing(fn(Model $record) => $record->name)
Saifallak
Saifallak15mo ago
->getOptionLabelFromRecordUsing(fn(Model $record) => filled($record->translate('name', app()->getLocale())) ? $record->translate('name', app()->getLocale()) : collect($record->getTranslations('name'))->first())
->getOptionLabelFromRecordUsing(fn(Model $record) => filled($record->translate('name', app()->getLocale())) ? $record->translate('name', app()->getLocale()) : collect($record->getTranslations('name'))->first())
because if translation not found in current locale, then it will just display the id, and thats ugly, so this check displays first language if current not found
Want results from more Discord servers?
Add your server