Skip to content

Filament v4 Schema-Based Forms, Infolists, and the Unified Schema API

Filament v4 replaces scattered form and infolist component trees with a single Schema API. Learn how unified schemas reduce duplication, enable reuse, and change how you think about building admin UIs.

Published · Updated · 3 min read

Filament v4 Schema-Based Forms, Infolists, and the Unified Schema API

Why Filament v4 Rethought the Component Tree

In Filament v3, forms and infolists were parallel but separate systems. A TextInput lived in Filament\Forms\Components while its read-only counterpart TextEntry lived in Filament\Infolists\Components. Keeping them in sync across a resource meant duplicating field definitions — a maintenance burden that grew with every new attribute.

Filament v4 introduces the unified Schema API: a single component tree that renders correctly in both edit and view contexts depending on where it is mounted. The mental model shifts from "define a form, then define an infolist" to "define a schema once, let the panel decide how to render it."


The Schema Class

At the core is Filament\Schemas\Schema. A resource's form() and infolist() methods both accept a Schema instance:

use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;

public static function schema(Schema $schema): Schema
{
    return $schema->components([
        TextInput::make('name')
            ->required()
            ->maxLength(255),

        Select::make('status')
            ->options(Status::class)
            ->required(),
    ]);
}

When this schema is mounted inside a CreateRecord or EditRecord page, components behave as form inputs. When mounted inside a ViewRecord page or an infolist panel, the same components render as read-only entries — no separate TextEntry::make('name') required.


Reusable Schema Fragments

The real payoff is extracting shared schema fragments into dedicated classes:

namespace App\Filament\Schemas;

use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;

class AddressSchema
{
    public static function make(): array
    {
        return [
            TextInput::make('address_line_1')->required(),
            TextInput::make('address_line_2'),
            TextInput::make('city')->required(),
            TextInput::make('postcode')
                ->regex('/^[A-Z0-9 ]{5,8}$/i'),
        ];
    }
}

Any resource that deals with addresses spreads this in:

return $schema->components([
    ...AddressSchema::make(),
    TextInput::make('vat_number'),
]);

One change to AddressSchema propagates everywhere — forms, infolists, and modal actions alike.


Context-Aware Components

Some components still need to behave differently in edit vs. view mode. The ->editableIn() and ->viewableIn() modifiers let you tune this without splitting the schema:

TextInput::make('email')
    ->email()
    ->required()
    ->disabledOn('view'),

For richer divergence, the ->schema() method on a Section accepts a closure that receives the current $operation:

Section::make('Credentials')
    ->schema(fn (string $operation): array => match ($operation) {
        'view' => [TextEntry::make('email')],
        default => [TextInput::make('email')->required()],
    }),

This escape hatch keeps the unified model intact while accommodating edge cases.


Infolist-Only Entries Still Exist

Not everything maps cleanly. ImageEntry, ColorEntry, and custom infolist-only entries remain in Filament\Infolists\Components and are only meaningful in view contexts. The unified schema does not force every component to be dual-purpose — it simply removes the requirement to duplicate the common ones.


Practical Migration Pattern

When upgrading a v3 resource:

  1. Identify fields that appear in both form() and infolist() with matching names.
  2. Replace the infolist entries with their form counterparts where a direct equivalent exists.
  3. Extract the shared components into a static schema class.
  4. Keep infolist-only entries (ImageEntry, etc.) in a dedicated ->schema() closure guarded by $operation === 'view'.

Takeaways

  • The unified Schema API eliminates the form/infolist duplication that plagued v3 resources.
  • Schema fragment classes are the idiomatic way to share field definitions across resources and actions.
  • Context-aware modifiers (disabledOn, operation closures) handle the minority of cases that genuinely differ between edit and view.
  • Infolist-only components still exist; the unified model is additive, not a forced abstraction.
  • Migrating incrementally — resource by resource — is safe and low-risk.

Frequently asked questions

Does the unified Schema API mean I can no longer use infolist-specific entries like ImageEntry?

No. Infolist-only entries such as ImageEntry still exist and work as before. The unified schema removes duplication for components that have both form and view representations, but does not eliminate entries that are inherently display-only.

Can I use schema fragment classes inside modal actions, not just full-page resources?

Yes. Any place that accepts a schema — CreateAction, EditAction, custom modal actions — can spread a fragment class array into its component list, giving you the same reuse benefit outside of resource pages.

Is it safe to migrate a single resource to the unified schema while leaving others in v3 style?

Filament v4 supports incremental adoption. Resources that still define separate form() and infolist() methods continue to work. You can migrate one resource at a time without affecting the rest of the panel.

Mohamed Said

About the author

Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

About GitHub LinkedIn WhatsApp Email Address My CV

Have a technical challenge?

Tell me what you’re building. I reply within two working days.

Discuss your project