Accept the option picked in selects of translatable records
Saving a page with a category failed with "El campo categoría no está
en la lista de valores permitidos" — for every category, not only the
one being tried. Filament builds such a list through a query, which
handles `->relationship('category', 'name->es')`, but validates a choice
by reading the title back off the record as a property,
`$record->{'name->es'}`, which does not exist. No label, so every
option was refused.
The same pattern was in seven more places: a call's, a testimonial's,
a talk's and a repository's project, a testimonial's service, and the
page and application filters. TranslatedOptionLabel gives Filament the
record's own translation instead, in the language of whoever uses the
panel; the JSON path stays for search and ordering.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Filament\Resources\Talks\Pages\CreateTalk;
|
||||
use App\Filament\Resources\Talks\Pages\EditTalk;
|
||||
use App\Filament\Resources\Talks\Pages\ListTalks;
|
||||
use App\Filament\Support\TranslatableTabs;
|
||||
use App\Filament\Support\TranslatedOptionLabel;
|
||||
use App\Models\Talk;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
@@ -126,6 +127,7 @@ class TalkResource extends Resource
|
||||
Select::make('project_id')
|
||||
->label(__('panel.talks.fields.project'))
|
||||
->relationship('project', 'title->'.config('locales.default'))
|
||||
->getOptionLabelFromRecordUsing(TranslatedOptionLabel::using('title'))
|
||||
->searchable()
|
||||
->preload(),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user