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:
- Identify fields that appear in both
form()andinfolist()with matching names. - Replace the infolist entries with their form counterparts where a direct equivalent exists.
- Extract the shared components into a static schema class.
- 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.