信息列表
概述
简介

Entry 类可以在 Filament\Infolists\Components
命名空间中找到。它们位于组件的 Schema 数组中。Filament 包含许多内置的 Entry:
你也可以创建自定义 Entry,以你希望的形式显示数据。
条目(Entry)可以使用静态 make()
方法创建,传入其唯一名称。通常,Entry 的名称对应于 Eloquent 模型的属性名。你可以使用“点语法”访问关联中的属性:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
TextEntry::make('author.name')

Entry 内容 (state)
Entry 旨在提供一种简单易用、优化展示 Eloquent 记录数据的方式。尽管如此,它很灵活,你可以展示任何来源的数据,不只是 Eloquent 记录的属性。
Entry 展示的数据称为“状态”。当使用面板资源时,信息列表了解它们要展示的记录。也就是说,Entry 的状态是基于记录的属性值设置的。比如,如果 Entry 用在 PostResource
的信息列表中,那么当前贴文(post)的 title
属性值将会被显示。
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
如果你想访问存储在关联中的值,你可以使用“点语法”。首先是你要访问数据的关联名,随后紧跟着点号,然后是属性名:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('author.name')
你也可以使用“点语法”访问 Eloquent 模型中的 JSON/数组字段的值。首先是属性名,紧随着点号,最后是你想要读取的 JSON 对象的键名:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('meta.title')
设置 Entry 状态
使用 state()
方法,你可以将你自己的状态传入到 Entry 中:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->state('Hello, world!')
state()
方法也可以接受函数来动态计算其状态。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
设置 Entry 的默认状态
当 Entry 为空(其状态值为 null
)时,你可以使用 default()
方法定义要使用的备用状态值。该方法将会视默认状态为真实状态,使得像图片或者颜色这些 Entry 可以展示默认图片或者颜色。
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->default('Untitled')
Entry 为空时添加占位符文本
有时,你想在 Entry 为空状态值式显示占位符文本,其使用青灰色文本。这与默认值不同,因为占位符永远是文本,且不会被当作真实状态。
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->placeholder('Untitled')

设置 Entry 的标签
默认情况下,Entry 的标签(展示在信息列表头部),是由 Entry 的名称生成。你可以使用 label()
方法对其自定义:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->label('Full name')
除了允许静态值之外,label()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
如果你想本地化翻译字符,以此方式自定义标签很有用:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->label(__('entries.name'))
隐藏 Entry 标签
TIP
如果你想要隐藏条目(Entry)的标签,可能是因为你尝试将条目用于任意文本或 UI。条目专门设计用于以结构化方式显示数据,而 Prime 组件 是用于渲染基本独立静态内容(例如文本、图像和按钮(操作))的简单组件。你可以考虑使用 Prime 组件。
将标签设置为空字符串来隐藏它可能很诱人,但不建议这样做。即使标签的用途在视觉上很清晰,将其设置为空字符串也无法向屏幕阅读器传达条目的用途。你应该使用 hiddenLabel()
方法,这样虽然在视觉上隐藏了标签,但屏幕阅读器仍然可以访问它:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->hiddenLabel()
或者,你也可以传入布尔值以控制是否隐藏标签:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->hiddenLabel(FeatureFlag::active())
除了允许静态值之外,hiddenLabel()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
点击 Entry 时打开 URL
使用 url()
方法,并传入一个 URL,你可以点击 Entry 来打开 URL。
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->url('/about/titles')
你也可以传入一个函数到 url()
方法中,来动态计算 通过将 $record
作为参数注入,你可以访问对应信息列表的当前 Eloquent 记录:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->url(fn (Post $record): string => route('posts.edit', ['post' => $record]))
如果你使用了面板资源,你可以使用 getUrl()
方法为该记录生成到页面的链接:
use App\Filament\Posts\PostResource;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->url(fn (Post $record): string => PostResource::getUrl('edit', ['record' => $record]))
The function passed to url()
can inject various utilities as parameters.
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
你也可以选择在新标签页中打开 URL:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->url(fn (Post $record): string => PostResource::getUrl('edit', ['record' => $record]))
->openUrlInNewTab()
或者,你也可以传入一个布尔值,用以控制 URL 是否应该在新标签页中打开:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->url(fn (Post $record): string => PostResource::getUrl('edit', ['record' => $record]))
->openUrlInNewTab(FeatureFlag::active())
除了允许静态值之外,openUrlInNewTab()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
隐藏 Entry
你可以隐藏 Entry:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('role')
->hidden()
或者,你也可以传入一个布尔值,以控制是否隐藏 Entry:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('role')
->hidden(! FeatureFlag::active())
除了允许静态值之外,hidden()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
此外,你也可以使用 visible()
方法来控制是否隐藏条目。在某些情况下,此方法可以让你的代码更具可读性:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('role')
->visible(FeatureFlag::active())
除了允许静态值之外,visible()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
NOTE
如果同时使用了 hidden()
和 visible()
方法,那么它们都需要告知该条目是否应该展示。
使用 JavaScript 隐藏 Entry
If you need to hide an entry based on a user interaction, you can use the hidden()
or visible()
methods, passing a function that uses utilities injected to determine whether the entry should be hidden or not:
use Filament\Forms\Components\Select;
use Filament\Infolists\Components\IconEntry;
Select::make('role')
->options([
'user' => 'User',
'staff' => 'Staff',
])
->live()
IconEntry::make('is_admin')
->boolean()
->hidden(fn (Get $get): bool => $get('role') !== 'staff')
In this example, the role
field is set to live()
, which means that the schema will reload the schema each time the role
field is changed. This will cause the function that is passed to the hidden()
method to be re-evaluated, which will hide the is_admin
entry if the role
field is not set to staff
.
However, reloading the schema each time an entry causes a network request to be made, since there is no way to re-run the PHP function from the client-side. This is not ideal for performance.
Alternatively, you can write JavaScript to hide the entry based on the value of a field. This is done by passing a JavaScript expression to the hiddenJs()
method:
use Filament\Forms\Components\Select;
use Filament\Infolists\Components\IconEntry;
Select::make('role')
->options([
'user' => 'User',
'staff' => 'Staff',
])
IconEntry::make('is_admin')
->boolean()
->hiddenJs(<<<'JS'
$get('role') !== 'staff'
JS)
Although the code passed to hiddenJs()
looks very similar to PHP, it is actually JavaScript. Filament provides the $get()
utility function to JavaScript that behaves very similar to its PHP equivalent, but without requiring the depended-on entry to be live()
.
The visibleJs()
method is also available, which works in the same way as hiddenJs()
, but controls if the entry should be visible or not:
use Filament\Forms\Components\Select;
use Filament\Infolists\Components\IconEntry;
Select::make('role')
->options([
'user' => 'User',
'staff' => 'Staff',
])
IconEntry::make('is_admin')
->boolean()
->visibleJs(<<<'JS'
$get('role') === 'staff'
JS)
NOTE
If both hiddenJs()
and visibleJs()
are used, they both need to indicate that the entry should be visible for it to be shown.
基于当前操作隐藏 Entry
The “operation” of a schema is the current action being performed on it. Usually, this is either create
, edit
or view
, if you are using the panel resource.
You can hide an entry based on the current operation by passing an operation to the hiddenOn()
method:
use Filament\Infolists\Components\IconEntry;
IconEntry::make('is_admin')
->boolean()
->hiddenOn('edit')
// is the same as
IconEntry::make('is_admin')
->boolean()
->hidden(fn (string $operation): bool => $operation === 'edit')
You can also pass an array of operations to the hiddenOn()
method, and the entry will be hidden if the current operation is any of the operations in the array:
use Filament\Infolists\Components\IconEntry;
IconEntry::make('is_admin')
->boolean()
->hiddenOn(['edit', 'view'])
// is the same as
IconEntry::make('is_admin')
->boolean()
->hidden(fn (string $operation): bool => in_array($operation, ['edit', 'view']))
NOTE
The hiddenOn()
method will overwrite any previous calls to the hidden()
method, and vice versa.
Alternatively, you may use the visibleOn()
method to control if the entry should be hidden or not. In some situations, this may help to make your code more readable:
use Filament\Infolists\Components\IconEntry;
IconEntry::make('is_admin')
->boolean()
->visibleOn('create')
IconEntry::make('is_admin')
->boolean()
->visibleOn(['create', 'edit'])
NOTE
The visibleOn()
method will overwrite any previous calls to the visible()
method, and vice versa.
行内标签
Entries may have their labels displayed inline with the entry, rather than above it. This is useful for infolists with many entries, where vertical space is at a premium. To display an entry’s label inline, use the inlineLabel()
method:
use Filament\Infolists\Components\TextEntry;
TextInput::make('name')
->inlineLabel()

Optionally, you may pass a boolean value to control if the label should be displayed inline or not:
use Filament\Infolists\Components\TextInput;
TextInput::make('name')
->inlineLabel(FeatureFlag::active())
除了允许静态值之外,inlineLabel()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
一次性在多处使用行内标签
If you wish to display all labels inline in a layout component like a section or tab, you can use the inlineLabel()
on the component itself, and all entries within it will have their labels displayed inline:
use Filament\Infolists\Components\TextInput;
use Filament\Schemas\Components\Section;
Section::make('Details')
->inlineLabel()
->entries([
TextInput::make('name'),
TextInput::make('email')
->label('Email address'),
TextInput::make('phone')
->label('Phone number'),
])

You can also use inlineLabel()
on the entire schema to display all labels inline:
use Filament\Schemas\Schema;
public function infolist(Schema $schema): Schema
{
return $schema
->inlineLabel()
->components([
// ...
]);
}
When using inlineLabel()
on a layout component or schema, you can still opt-out of inline labels for individual entries by using the inlineLabel(false)
method on the entry:
use Filament\Infolists\Components\TextInput;
use Filament\Schemas\Components\Section;
Section::make('Details')
->inlineLabel()
->entries([
TextInput::make('name'),
TextInput::make('email')
->label('Email address'),
TextInput::make('phone')
->label('Phone number')
->inlineLabel(false),
])
Adding a tooltip to an entry
You may specify a tooltip to display when you hover over an entry:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->tooltip('Shown at the top of the page')
除了允许静态值之外,tooltip()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

对齐 Entry 内容
You may align the content of an entry to the start (left in left-to-right interfaces, right in right-to-left interfaces), center, or end (right in left-to-right interfaces, left in right-to-left interfaces) using the alignStart()
, alignCenter()
or alignEnd()
methods:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->alignStart() // This is the default alignment.
TextEntry::make('title')
->alignCenter()
TextEntry::make('title')
->alignEnd()
Alternatively, you may pass an Alignment
enum to the alignment()
method:
use Filament\Infolists\Components\TextEntry;
use Filament\Support\Enums\Alignment;
TextEntry::make('title')
->alignment(Alignment::Center)
除了允许静态值之外,alignment()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
Adding extra content to an entry
Entries contain many “slots” where content can be inserted in a child schema. Slots can accept text, any schema component, actions and action groups. Usually, prime components are used for content.
The following slots are available for all entries:
aboveLabel()
beforeLabel()
afterLabel()
belowLabel()
aboveContent()
beforeContent()
afterContent()
belowContent()
As well as allowing static values, the slot methods also accept functions to dynamically calculate them. You can inject various utilities into the functions as parameters.
Learn more about utility injection.Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
To insert plain text, you can pass a string to these methods:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->belowContent('This is the user\'s full name.')

To insert a schema component, often a prime component, you can pass the component to the method:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Text;
use Filament\Support\Enums\FontWeight;
TextEntry::make('name')
->belowContent(Text::make('This is the user\'s full name.')->weight(FontWeight::Bold))

To insert an action or action group, you can pass the action or action group to the method:
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->belowContent(Action::make('generate'))

You can insert any combination of content into the slots by passing an array of content to the method:
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->belowContent([
Icon::make(Heroicon::InformationCircle),
'This is the user\'s full name.',
Action::make('generate'),
])

You can also align the content in the slots by passing the array of content to either Schema::start()
(default), Schema::end()
or Schema::between()
:
use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Flex;
use Filament\Schemas\Components\Icon;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->belowContent(Schema::end([
Icon::make(Heroicon::InformationCircle),
'This is the user\'s full name.',
Action::make('generate'),
]))
TextEntry::make('name')
->belowContent(Schema::between([
Icon::make(Heroicon::InformationCircle),
'This is the user\'s full name.',
Action::make('generate'),
]))
TextEntry::make('name')
->belowContent(Schema::between([
Flex::make([
Icon::make(Heroicon::InformationCircle)
->grow(false),
'This is the user\'s full name.',
]),
Action::make('generate'),
]))
TIP
As you can see in the above example for Schema::between()
, a Flex
component is used to group the icon and text together so they do not have space between them. The icon uses grow(false)
to prevent it from taking up half of the horizontal space, allowing the text to consume the remaining space.

Adding extra content above an entry’s label
You can insert extra content above an entry’s label using the aboveLabel()
method. You can pass any content to this method, like text, a schema component, an action, or an action group:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->aboveLabel([
Icon::make(Heroicon::Star),
'This is the content above the entry\'s label'
])
除了允许静态值之外,aboveLabel()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

Adding extra content before an entry’s label
You can insert extra content before an entry’s label using the beforeLabel()
method. You can pass any content to this method, like text, a schema component, an action, or an action group:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->beforeLabel(Icon::make(Heroicon::Star))
除了允许静态值之外,beforeLabel()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

Adding extra content after an entry’s label
You can insert extra content after an entry’s label using the afterLabel()
method. You can pass any content to this method, like text, a schema component, an action, or an action group:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->afterLabel([
Icon::make(Heroicon::Star),
'This is the content after the entry\'s label'
])
除了允许静态值之外,afterLabel()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

By default, the content in the afterLabel()
schema is aligned to the end of the container. If you wish to align it to the start of the container, you should pass a Schema::start()
object containing the content:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->afterLabel(Schema::start([
Icon::make(Heroicon::Star),
'This is the content after the entry\'s label'
]))
除了允许静态值之外,afterLabel()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

Adding extra content below an entry’s label
You can insert extra content below an entry’s label using the belowLabel()
method. You can pass any content to this method, like text, a schema component, an action, or an action group:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->belowLabel([
Icon::make(Heroicon::Star),
'This is the content below the entry\'s label'
])
除了允许静态值之外,belowLabel()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

NOTE
This may seem like the same as the aboveContent()
method. However, when using inline labels, the aboveContent()
method will place the content above the entry, not below the label, since the label is displayed in a separate column to the entry content.
Adding extra content above an entry’s content
You can insert extra content above an entry’s content using the aboveContent()
method. You can pass any content to this method, like text, a schema component, an action, or an action group:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->aboveContent([
Icon::make(Heroicon::Star),
'This is the content above the entry\'s content'
])
除了允许静态值之外,aboveContent()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

NOTE
This may seem like the same as the belowLabel()
method. However, when using inline labels, the belowLabel()
method will place the content below the label, not above the entry’s content, since the label is displayed in a separate column to the entry content.
Adding extra content before an entry’s content
You can insert extra content before an entry’s content using the beforeContent()
method. You can pass any content to this method, like text, a schema component, an action, or an action group:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->beforeContent(Icon::make(Heroicon::Star))
除了允许静态值之外,beforeContent()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

Adding extra content after an entry’s content
You can insert extra content after an entry’s content using the afterContent()
method. You can pass any content to this method, like text, a schema component, an action, or an action group:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->afterContent(Icon::make(Heroicon::Star))
除了允许静态值之外,afterContent()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |

Adding extra HTML attributes to an entry
You can pass extra HTML attributes to the entry via the extraAttributes()
method, which will be merged onto its outer HTML element. The attributes should be represented by an array, where the key is the attribute name and the value is the attribute value:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('slug')
->extraAttributes(['class' => 'bg-gray-200'])
除了允许静态值之外,extraAttributes()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
By default, calling extraAttributes()
multiple times will overwrite the previous attributes. If you wish to merge the attributes instead, you can pass merge: true
to the method.
Adding extra HTML attributes to the entry wrapper
You can also pass extra HTML attributes to the very outer element of the “entry wrapper” which surrounds the label and content of the entry. This is useful if you want to style the label or spacing of the entry via CSS, since you could target elements as children of the wrapper:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('slug')
->extraEntryWrapperAttributes(['class' => 'components-locked'])
除了允许静态值之外,extraEntryWrapperAttributes()
方法也可以接受函数来动态计算其值。你可以将各种 utility 作为参数注入到函数中。
Learn more about utility injection.
Utility | Type | Parameter | Description |
---|---|---|---|
Entry | Filament\Infolists\Components\Entry | $component | The current entry component instance. |
Get function | Filament\Schemas\Components\Utilities\Get | $get | A function for retrieving values from the current schema data. Validation is not run on form fields. |
Livewire | Livewire\Component | $livewire | The Livewire component instance. |
Eloquent model FQN | ?string<Illuminate\Database\Eloquent\Model> | $model | The Eloquent model FQN for the current schema. |
Operation | string | $operation | The current operation being performed by the schema. Usually create , edit , or view . |
Eloquent record | ?Illuminate\Database\Eloquent\Model | $record | The Eloquent record for the current schema. |
State | mixed | $state | The current value of the entry. |
By default, calling extraEntryWrapperAttributes()
multiple times will overwrite the previous attributes. If you wish to merge the attributes instead, you can pass merge: true
to the method.
Entry utility injection
The vast majority of methods used to configure entries accept functions as parameters instead of hardcoded values:
use App\Models\User;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->label(fn (string $state): string => str_contains($state, ' ') ? 'Full name' : 'Name')
TextEntry::make('currentUserEmail')
->state(fn (): string => auth()->user()->email)
TextEntry::make('role')
->hidden(fn (User $record): bool => $record->role === 'admin')
This alone unlocks many customization possibilities.
The package is also able to inject many utilities to use inside these functions, as parameters. All customization methods that accept functions as arguments can inject utilities.
These injected utilities require specific parameter names to be used. Otherwise, Filament doesn’t know what to inject.
注入条目的当前状态
If you wish to access the current value (state) of the entry, define a $state
parameter:
function ($state) {
// ...
}
Injecting the state of another entry or form field
You may also retrieve the state (value) of another entry or form field from within a callback, using a $get
parameter:
use Filament\Schemas\Components\Utilities\Get;
function (Get $get) {
$email = $get('email'); // Store the value of the `email` entry in the `$email` variable.
//...
}
TIP
Unless a form field is reactive, the schema will not refresh when the value of the field changes, only when the next user interaction occurs that makes a request to the server. If you need to react to changes in a field’s value, it should be live()
.
注入当前 Eloquent 记录
You may retrieve the Eloquent record for the current schema using a $record
parameter:
use Illuminate\Database\Eloquent\Model;
function (?Model $record) {
// ...
}
注入当前操作
If you’re writing a schema for a panel resource or relation manager, and you wish to check if a schema is create
, edit
or view
, use the $operation
parameter:
function (string $operation) {
// ...
}
NOTE
You can manually set a schema’s operation using the $schema->operation()
method.
注入当前 Livewire 组件实例
If you wish to access the current Livewire component instance, define a $livewire
parameter:
use Livewire\Component;
function (Component $livewire) {
// ...
}
注入当前条目实例
If you wish to access the current component instance, define a $component
parameter:
use Filament\Infolists\Components\Entry;
function (Entry $component) {
// ...
}
注入各种 utility
The parameters are injected dynamically using reflection, so you are able to combine multiple parameters in any order:
use App\Models\User;
use Filament\Schemas\Components\Utilities\Get;
use Livewire\Component as Livewire;
function (Livewire $livewire, Get $get, User $record) {
// ...
}
注入来自 Laravel 容器的依赖
You may inject anything from Laravel’s container like normal, alongside utilities:
use App\Models\User;
use Illuminate\Http\Request;
function (Request $request, User $record) {
// ...
}
全局设置
If you wish to change the default behavior of all entries globally, then you can call the static configureUsing()
method inside a service provider’s boot()
method, to which you pass a Closure to modify the entries using. For example, if you wish to make all TextEntry
components words(10)
, you can do it like so:
use Filament\Infolists\Components\TextEntry;
TextEntry::configureUsing(function (TextEntry $entry): void {
$entry->words(10);
});
Of course, you are still able to overwrite this on each entry individually:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->words(null)
Edit on GitHubStill need help? Join our Discord community or open a GitHub discussion