占位符
概述
占位符(Placeholder)可用于在表单中渲染只读字段。每个占位符都有其内容 - content(),用户不能修改。
use App\Models\Post;
use Filament\Forms\Components\Placeholder;
Placeholder::make('created')
->content(fn (Post $record): string => $record->created_at->toFormattedDateString())

重要: 所有表单字段都要求唯一名称。这同样适用于占位符字段!
在占位符字段内渲染 HTML
你甚至可以在占位符内容中渲染 HTML:
use Filament\Forms\Components\Placeholder;
use Illuminate\Support\HtmlString;
Placeholder::make('documentation')
->content(new HtmlString('<a href="https://filamentphp.com/docs">filamentphp.com</a>'))
