FilamentF
Filament3y ago
John

Global translation for all model fields?

I'd like to use a nested array with models and translated field names. And use them globally for columns and fields:

<?php

namespace App\Providers;

use Filament\Forms\Components\Field;
use Illuminate\Support\ServiceProvider;

class FilamentServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Field::configureUsing(function (Field $field) {
            $model = 'post';
            $fieldName = $field->getName();
            $field->label(__("models.$model.$fieldName"));
        });
    }
}

Is there any way to dynamically determine the $model from the calling component?
Was this page helpful?