概述
简介


Filament 的 infolists 包可让你为特定实体展示只读数据列表。它已集成到其他 Filament 包中,例如 面板资源、关联管理器 和 操作模态框。掌握 infolist 构建器的用法,能在构建自定义 Livewire 应用或使用其他 Filament 功能时节省时间。
本指南介绍使用 Filament 构建信息列表(infolist)的基础知识。若要把 infolist 加到自己的 Livewire 组件中,请先从这里开始再继续。若是把 infolist 加到 面板资源 或其他 Filament 包中,可以直接开始!
定义条目
条目类位于 Filament\Infolists\Components 命名空间中,放在组件的 schema 数组里。Filament 内置多种条目:
你也可以创建自定义条目,按任意方式展示数据。
可使用静态方法 make() 创建条目,并传入其唯一名称。通常,条目名对应 Eloquent 模型上的属性名。你可以使用「点语法(dot notation)」访问关系中的属性:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
TextEntry::make('author.name')

条目内容(状态)
条目起初可能显得有些「魔法」,但它们被设计为易于使用,并针对展示 Eloquent 记录中的数据做了优化。尽管如此,它们也很灵活,你可以展示来自任意来源的数据,而不仅限于 Eloquent 记录属性。
条目展示的数据称为其「状态(state)」。使用 面板资源 时,infolist 知道正在展示的记录。因此条目状态会根据记录上该属性的值来设置。例如,若条目用在 PostResource 的 infolist 中,则会展示当前文章的 title 属性值。
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')若要访问存储在关系中的值,可以使用「点语法(dot notation)」。先写要访问数据的关系名,再加一个点,然后是属性名:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('author.name')你也可以使用「点语法(dot notation)」访问 Eloquent 模型上 JSON / 数组列中的值。先写属性名,再加一个点,然后是要读取的 JSON 对象的键:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('meta.title')设置条目的状态
你可以使用 state() 方法向条目传入自己的状态:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->state('Hello, world!')TIP
state() 方法也接受函数以动态计算状态。你可以将各种工具作为参数注入到该函数中。
设置条目的默认状态
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->default('Untitled')条目为空时添加占位文本
有时你可能希望为空状态的条目显示占位文本,样式为较浅的灰色文字。这与默认值不同:占位符始终是文本,不会被当作真实状态。
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->placeholder('Untitled')

设置条目标签
默认情况下,显示在 infolist 头部的条目标签会根据条目名称生成。你可以使用 label() 方法自定义:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->label('Full name')TIP
除了允许静态值外,label() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
以这种方式自定义标签很有用,尤其是当你希望使用 用于本地化的翻译字符串 时:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->label(__('entries.name'))隐藏条目标签
TIP
若你想隐藏条目标签,可能其实是想用条目来放任意文本或 UI。条目专门用于结构化展示数据,而 Prime 组件 是用于渲染独立静态内容的简单组件,例如文本、图片和按钮(操作)。你可能更适合改用 Prime 组件。
或许会想把标签设为空字符串来隐藏它,但不推荐这样做。即使视觉上用途很明确,空字符串标签也无法向屏幕阅读器传达条目用途。应改用 hiddenLabel() 方法,使其在视觉上隐藏,但对屏幕阅读器仍然可访问:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->hiddenLabel()

可选地,你可以传入布尔值来控制是否隐藏标签:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->hiddenLabel(FeatureFlag::active())TIP
除了允许静态值外,hiddenLabel() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
点击条目时打开 URL
点击条目时可以打开 URL。做法是向 url() 方法传入 URL:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->url('/about/titles')你可以向 url() 方法传入函数以动态计算 URL。例如,可通过注入 $record 参数访问 infolist 当前的 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]))TIP
传给 url() 的函数可以将各种工具作为参数注入。
你也可以选择在新标签页中打开 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())TIP
除了允许静态值外,openUrlInNewTab() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
DANGER
若向 url() 方法传入用户可控的数据,应校验该 URL 未使用 javascript: 或 data: 等危险协议。否则可能使应用暴露于 XSS 攻击。最简单的防护方式是用 Filament 的 Str::sanitizeUrl() 辅助函数包裹该值:对未使用 http/https(或相对路径)的 URL,它会返回 null。
隐藏条目
你可以隐藏条目:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('role')
->hidden()可选地,你可以传入布尔值来控制是否隐藏条目:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('role')
->hidden(! FeatureFlag::active())TIP
除了允许静态值外,hidden() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
或者,你可以使用 visible() 方法来控制条目是否隐藏。在某些情况下,这可能让代码更易读:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('role')
->visible(FeatureFlag::active())TIP
除了允许静态值外,visible() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
INFO
若同时使用了 hidden() 和 visible(),两者都必须表明条目应可见,条目才会显示。
使用 JavaScript 隐藏条目
若需要根据用户交互隐藏条目,可使用 hidden() 或 visible() 方法,并传入一个利用注入工具来判断是否应隐藏条目的函数:
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')本例中,role 字段设置了 live(),这意味着每次更改 role 字段时 schema 都会重新加载。这会使传给 hidden() 的函数重新求值;若 role 未设为 staff,则会隐藏 is_admin 条目。
然而,每次条目变化都重新加载 schema 会发起网络请求,因为无法在客户端重新运行 PHP 函数。这对性能并不理想。
或者,你可以编写 JavaScript,根据某字段的值来隐藏条目。做法是向 hiddenJs() 方法传入 JavaScript 表达式:
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)虽然传给 hiddenJs() 的代码看起来很像 PHP,但它实际是 JavaScript。Filament 为 JavaScript 提供了 $get() 工具函数,行为与 PHP 版本非常相似,但不要求所依赖的条目为 live()。
也提供了 visibleJs() 方法,工作方式与 hiddenJs() 相同,但用于控制条目是否可见:
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)INFO
若同时使用了 hiddenJs() 和 visibleJs(),两者都必须表明条目应可见,条目才会显示。
根据当前操作隐藏条目
schema 的「操作(operation)」是当前对其执行的动作。若使用 面板资源,通常是 create、edit 或 view。
你可以通过向 hiddenOn() 方法传入操作,根据当前操作隐藏条目:
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')你也可以向 hiddenOn() 方法传入操作数组;若当前操作属于该数组中的任一操作,条目将被隐藏:
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']))WARNING
hiddenOn() 方法会覆盖此前对 hidden() 方法的任何调用,反之亦然。
或者,你可以使用 visibleOn() 方法来控制条目是否隐藏。在某些情况下,这可能让代码更易读:
use Filament\Infolists\Components\IconEntry;
IconEntry::make('is_admin')
->boolean()
->visibleOn('create')
IconEntry::make('is_admin')
->boolean()
->visibleOn(['create', 'edit'])INFO
visibleOn() 方法会覆盖此前对 visible() 方法的任何调用,反之亦然。
行内标签
条目标签可以与条目同行显示,而不是显示在上方。这对条目很多、纵向空间紧张的 infolist 很有用。要让条目标签行内显示,请使用 inlineLabel() 方法:
use Filament\Infolists\Components\TextEntry;
TextInput::make('name')
->inlineLabel()

可选地,你可以传入布尔值来控制标签是否行内显示:
use Filament\Infolists\Components\TextInput;
TextInput::make('name')
->inlineLabel(FeatureFlag::active())TIP
除了允许静态值外,inlineLabel() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
一次在多处使用行内标签
若希望在 布局组件(如 分区(section) 或 标签页(tab))中让所有标签都行内显示,可在该组件本身上使用 inlineLabel(),其内所有条目的标签都会行内显示:
use Filament\Infolists\Components\TextInput;
use Filament\Schemas\Components\Section;
Section::make('Details')
->inlineLabel()
->schema([
TextInput::make('name'),
TextInput::make('email')
->label('Email address'),
TextInput::make('phone')
->label('Phone number'),
])

你也可以在整个 schema 上使用 inlineLabel(),让所有标签都行内显示:
use Filament\Schemas\Schema;
public function infolist(Schema $schema): Schema
{
return $schema
->inlineLabel()
->components([
// ...
]);
}在布局组件或 schema 上使用 inlineLabel() 时,仍可通过在单个条目上使用 inlineLabel(false) 退出行内标签:
use Filament\Infolists\Components\TextInput;
use Filament\Schemas\Components\Section;
Section::make('Details')
->inlineLabel()
->schema([
TextInput::make('name'),
TextInput::make('email')
->label('Email address'),
TextInput::make('phone')
->label('Phone number')
->inlineLabel(false),
])为条目添加工具提示
你可以指定悬停在条目上时显示的工具提示:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->tooltip('Shown at the top of the page')TIP
除了允许静态值外,tooltip() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


对齐条目内容
你可以使用 alignStart()、alignCenter() 或 alignEnd() 方法将条目内容对齐到起始端(从左到右界面为左,从右到左界面为右)、居中或末端(从左到右界面为右,从右到左界面为左):
use Filament\Infolists\Components\TextEntry;
TextEntry::make('title')
->alignStart() // This is the default alignment.
TextEntry::make('title')
->alignCenter()
TextEntry::make('title')
->alignEnd()或者,你可以向 alignment() 方法传入 Alignment 枚举:
use Filament\Infolists\Components\TextEntry;
use Filament\Support\Enums\Alignment;
TextEntry::make('title')
->alignment(Alignment::Center)TIP
除了允许静态值外,alignment() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


向条目添加额外内容
条目包含许多「插槽(slots)」,可在子 schema 中插入内容。插槽可接受文本、任意 schema 组件、操作(actions) 和 操作组。通常用 prime 组件 来放内容。
所有条目都可用以下插槽:
aboveLabel()beforeLabel()afterLabel()belowLabel()aboveContent()beforeContent()afterContent()belowContent()
TIP
除了允许静态值外,插槽方法也接受函数以动态计算。你可以将各种工具作为参数注入到这些函数中。
要插入纯文本,可以向这些方法传入字符串:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->belowContent('This is the user\'s full name.')

要插入 schema 组件(通常是 prime 组件),可将该组件传给方法:
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))

use Filament\Actions\Action;
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->belowContent(Action::make('generate'))

你可以通过向方法传入内容数组,将任意内容组合插入插槽:
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'),
])

你也可以通过将内容数组传给 Schema::start()(默认)、Schema::end() 或 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
如上例 Schema::between() 所示,使用 Flex 组件 将图标与文本组合在一起,使它们之间没有空隙。图标使用 grow(false) 以避免占据一半横向空间,从而让文本占用剩余空间。


在条目标签上方添加额外内容
你可以使用 aboveLabel() 方法在条目标签上方插入额外内容。可以向该方法传入任意内容,如文本、schema 组件、操作或操作组:
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'
])TIP
除了允许静态值外,aboveLabel() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


在条目标签之前添加额外内容
你可以使用 beforeLabel() 方法在条目标签之前插入额外内容。可以向该方法传入任意内容,如文本、schema 组件、操作或操作组:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->beforeLabel(Icon::make(Heroicon::Star))TIP
除了允许静态值外,beforeLabel() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


在条目标签之后添加额外内容
你可以使用 afterLabel() 方法在条目标签之后插入额外内容。可以向该方法传入任意内容,如文本、schema 组件、操作或操作组:
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'
])TIP
除了允许静态值外,afterLabel() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


默认情况下,afterLabel() schema 中的内容会对齐到容器末端。若希望对齐到容器起始端,应传入包含内容的 Schema::start() 对象:
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'
]))TIP
除了允许静态值外,afterLabel() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


在条目标签下方添加额外内容
你可以使用 belowLabel() 方法在条目标签下方插入额外内容。可以向该方法传入任意内容,如文本、schema 组件、操作或操作组:
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'
])TIP
除了允许静态值外,belowLabel() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


INFO
这看起来可能与 aboveContent() 方法 相同。但在使用 行内标签 时,aboveContent() 会把内容放在条目上方,而不是标签下方,因为标签与条目内容分列显示。
在条目内容上方添加额外内容
你可以使用 aboveContent() 方法在条目内容上方插入额外内容。可以向该方法传入任意内容,如文本、schema 组件、操作或操作组:
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'
])TIP
除了允许静态值外,aboveContent() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


INFO
这看起来可能与 belowLabel() 方法 相同。但在使用 行内标签 时,belowLabel() 会把内容放在标签下方,而不是条目内容上方,因为标签与条目内容分列显示。
在条目内容之前添加额外内容
你可以使用 beforeContent() 方法在条目内容之前插入额外内容。可以向该方法传入任意内容,如文本、schema 组件、操作或操作组:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->beforeContent(Icon::make(Heroicon::Star))TIP
除了允许静态值外,beforeContent() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


在条目内容之后添加额外内容
你可以使用 afterContent() 方法在条目内容之后插入额外内容。可以向该方法传入任意内容,如文本、schema 组件、操作或操作组:
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Icon;
use Filament\Support\Icons\Heroicon;
TextEntry::make('name')
->afterContent(Icon::make(Heroicon::Star))TIP
除了允许静态值外,afterContent() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。


向条目添加额外 HTML 属性
你可以通过 extraAttributes() 方法向条目传入额外 HTML 属性,这些属性会合并到其外层 HTML 元素上。属性应以数组表示,键为属性名,值为属性值:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('slug')
->extraAttributes(['class' => 'bg-gray-200'])TIP
除了允许静态值外,extraAttributes() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
默认情况下,多次调用 extraAttributes() 会覆盖先前的属性。若希望改为合并属性,可向方法传入 merge: true。
向条目包装器添加额外 HTML 属性
你也可以向包围条目标签与内容的「条目包装器(entry wrapper)」最外层元素传入额外 HTML 属性。若要通过 CSS 样式化标签或条目间距,这很有用,因为你可以把元素作为包装器的子元素来定位:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('slug')
->extraEntryWrapperAttributes(['class' => 'components-locked'])TIP
除了允许静态值外,extraEntryWrapperAttributes() 方法也接受函数以动态计算。你可以将各种工具作为参数注入到该函数中。
默认情况下,多次调用 extraEntryWrapperAttributes() 会覆盖先前的属性。若希望改为合并属性,可向方法传入 merge: true。
条目工具注入
绝大多数用于配置条目的方法都接受函数作为参数,而不是硬编码值:
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')仅此一点就解锁了许多自定义可能。
该包还能以参数形式向这些函数注入许多可用工具。所有接受函数作为参数的自定义方法都可以注入工具。
这些注入的工具要求使用特定的参数名。否则 Filament 不知道要注入什么。
注入条目的当前状态
若要访问条目的当前值(状态),请定义 $state 参数:
function ($state) {
// ...
}注入另一条目或表单字段的状态
你也可以在回调中使用 $get 参数获取另一条目或表单字段的状态(值):
use Filament\Schemas\Components\Utilities\Get;
function (Get $get) {
$email = $get('email'); // Store the value of the `email` entry in the `$email` variable.
//...
}TIP
除非表单字段是响应式的,否则字段值变化时 schema 不会刷新,只会在下一次会向服务器发请求的用户交互时刷新。若需要响应字段值的变化,应将其设为 live()。
注入当前 Eloquent 记录
你可以使用 $record 参数获取当前 schema 的 Eloquent 记录:
use Illuminate\Database\Eloquent\Model;
function (?Model $record) {
// ...
}注入当前操作
若正在为面板资源或关联管理器编写 schema,并希望检查 schema 是 create、edit 还是 view,请使用 $operation 参数:
function (string $operation) {
// ...
}INFO
你可以使用 $schema->operation() 方法手动设置 schema 的操作。
注入当前 Livewire 组件实例
若要访问当前 Livewire 组件实例,请定义 $livewire 参数:
use Livewire\Component;
function (Component $livewire) {
// ...
}注入当前条目实例
若要访问当前组件实例,请定义 $component 参数:
use Filament\Infolists\Components\Entry;
function (Entry $component) {
// ...
}注入多个工具
参数通过反射动态注入,因此你可以按任意顺序组合多个参数:
use App\Models\User;
use Filament\Schemas\Components\Utilities\Get;
use Livewire\Component as Livewire;
function (Livewire $livewire, Get $get, User $record) {
// ...
}从 Laravel 容器注入依赖
你可以像往常一样从 Laravel 容器注入任意内容,并与工具一起使用:
use App\Models\User;
use Illuminate\Http\Request;
function (Request $request, User $record) {
// ...
}全局设置
若希望全局更改所有条目的默认行为,可在 service provider 的 boot() 方法中调用静态方法 configureUsing(),并传入用于修改条目的 Closure。例如,若希望所有 TextEntry 组件都使用 words(10),可以这样做:
use Filament\Infolists\Components\TextEntry;
TextEntry::configureUsing(function (TextEntry $entry): void {
$entry->words(10);
});当然,你仍可以在每个条目上单独覆盖此设置:
use Filament\Infolists\Components\TextEntry;
TextEntry::make('name')
->words(null)