You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Filament自定义页面中使用Spatie Translatable插件

在Filament自定义页面中使用Spatie Translatable插件遇到问题

我在Filament中使用Spatie Translatable插件,该插件在Filament资源的列表、创建、编辑页面均可正常工作,但在自定义页面中使用时出现错误。

自定义页面代码

use Filament\Forms\Form;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Actions;
 
class EditCompany extends Page implements HasForms
{
    use InteractsWithForms;
    use EditRecord\Concerns\Translatable;
 
    public ?array $data = []; 
 
    protected static ?string $navigationIcon = 'heroicon-o-document-text';
 
    protected static string $view = 'filament.pages.edit-company';
 
    public function mount(): void 
    {
        $this->form->fill();
    }
 
    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('name')
                    ->required(),
            ])
            ->statePath('data');
    }

    protected function getHeaderActions(): array
    {
        return [
            Actions\LocaleSwitcher::make(),
        ];
    }
}

Blade文件代码

<x-filament-panels::page>
    <x-filament-panels::form>
        {{ $this->form }}
    </x-filament-panels::form>
</x-filament-panels::page>

我尝试引入use EditRecord\Concerns\Translatable;仍未解决问题,请问有人在自定义页面中使用过该插件,或是知道如何修复此错误吗?


内容的提问来源于stack exchange,提问作者John

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 06:32:17