Form Builder - Layout
Placeholder
Overview
Placeholders can be used to render text-only "fields" within your forms. Each placeholder has content()
, which cannot be changed by the user.
use App\Models\Post;use Filament\Forms\Components\Placeholder; Placeholder::make('created') ->content(fn (Post $record): string => $record->created_at->toFormattedDateString())
Important: All form fields require a unique name. That also applies to Placeholders!
Rendering HTML inside the placeholder
You may even render custom HTML within placeholder content:
use Filament\Forms\Components\Placeholder;use Illuminate\Support\HtmlString; Placeholder::make('documentation') ->content(new HtmlString('<a href="https://filamentphp.com/docs">filamentphp.com</a>'))
Dynamically generating placeholder content
By passing a closure to the content()
method, you may dynamically generate placeholder content. You have access to any closure parameter explained in the advanced closure customization documentation:
use Filament\Forms\Components\Placeholder;use Filament\Forms\Get; Placeholder::make('total') ->content(function (Get $get): string { return '€' . number_format($get('cost') * $get('quantity'), 2); })
Edit on GitHubStill need help? Join our Discord community or open a GitHub discussion