Custom components
Inserting a Blade view into a schema
You may use a "view" component to insert a Blade view into a schema arbitrarily:
use Filament\Schemas\Components\View;
View::make('filament.schemas.components.chart')
This assumes that you have a resources/views/filament/schemas/components/chart.blade.php
file.
Rendering the component's child schema
You may pass an array of child schema components to the schema()
method of the component:
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\View;
View::make('filament.schemas.components.chart')
->schema([
TextInput::make('subtotal'),
TextInput::make('total'),
])
Inside the Blade view, you may render the component's schema()
using the $getChildSchema()
function:
<div>
{{ $getChildSchema() }}
</div>
Accessing the state of another component in the Blade view
Inside the Blade view, you may access the state of another component in the schema using the $get()
function:
<div>
{{ $get('email') }}
</div>
TIP
Unless a form field is reactive, the Blade view 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()
.
Accessing the Eloquent record in the Blade view
Inside the Blade view, you may access the current Eloquent record using the $record
variable:
<div>
{{ $record->name }}
</div>
Accessing the current operation in the Blade view
Inside the Blade view, you may access the current operation, usually create
, edit
or view
, using the $operation
variable:
<p>
@if ($operation === 'create')
This is a new post.
@else
This is an existing post.
@endif
</p>