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

如何让PHP Filament中TextEntry的标签与内容并排显示?

在Filament中实现TextEntry标签与内容并排布局的最简方案

不用复杂的网格或Split布局,Filament的TextEntry组件自带实现并排布局的方法,直接调用inline()即可:

单个组件设置

给需要并排的TextEntry添加->inline()方法,修改后的代码如下:

Section::make('Datums')
    ->columnSpan(1)
    ->schema([
        TextEntry::make('apk_date')
            ->label('Apk Datum')
            ->inline() // 开启标签与内容并排
            ->badge()->color(function ($record) {
                $carbonApkDate = Carbon::parse($record->apk_date);
                if ($carbonApkDate->lt(now())) {
                    return 'red';
                } elseif ($carbonApkDate->lt(now()->addMonth())) {
                    return 'yellow';
                } else {
                    return 'green';
                }
            })
            ->columnSpan(2)
            ->date('d-m-Y'),
        TextEntry::make('end_date')
            ->label('End Date')
            ->inline() // 同样开启并排
            ->color('primary'),
        // 其他TextEntry组件同理添加inline()
    ]),

全局统一设置

如果希望所有TextEntry默认都用并排布局,无需逐个组件修改,可以在AppServiceProvider的boot方法中全局配置:

use Filament\Forms\Components\TextEntry;

public function boot()
{
    TextEntry::configureUsing(function (TextEntry $component) {
        $component->inline();
    });
}

内容的提问来源于stack exchange,提问作者Shot on Phone

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 05:12:11