© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
6 replies
APG

Using $get / $set with a Livewire::make() form component

I am desperately trying to create a modal with a select component that, when changed, can display some calculated things in the modal based on the selected amount.

This works to pass the default state of amount from coverage_amount, but amount doesn't change when the select field changes.

How can I access the current state of
coverage_amount
coverage_amount
inside the
PolicyPreview
PolicyPreview
livewire component?

->form([
    Select::make('coverage_amount')
        ->label('Amount')
        ->options(fn (CourtCase $case) => $case->getCoverageOptions())
        ->default(fn (CourtCase $case) => $case->firmRequestedDefaultCoverage())
        ->placeholder('Select coverage amount')
        ->live(),
    Livewire::make(PolicyPreview::class)
        ->data(fn (Get $get) => [
            'amount' => $get('coverage_amount'),
        ]),
])
->form([
    Select::make('coverage_amount')
        ->label('Amount')
        ->options(fn (CourtCase $case) => $case->getCoverageOptions())
        ->default(fn (CourtCase $case) => $case->firmRequestedDefaultCoverage())
        ->placeholder('Select coverage amount')
        ->live(),
    Livewire::make(PolicyPreview::class)
        ->data(fn (Get $get) => [
            'amount' => $get('coverage_amount'),
        ]),
])
Solution
You could use a ViewField

ViewField::make('amount')
->view('policy-preview')
ViewField::make('amount')
->view('policy-preview')


<!-- resources/views/policy-preview.blade.php -->
<div>
    {{ $getState() }}
</div>
<!-- resources/views/policy-preview.blade.php -->
<div>
    {{ $getState() }}
</div>


And use afterStateUpdated in the select to set the value

->afterStateUpdated(function (Set $set, ?string $state) {
    $set('amount', $state);
})
->afterStateUpdated(function (Set $set, ?string $state) {
    $set('amount', $state);
})
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Accessing form $data from an action using Livewire::make() form component in a modal
FilamentFFilament / ❓┊help
2y ago
Livewire Form Component problem
FilamentFFilament / ❓┊help
13mo ago
Form inside Livewire Component:
FilamentFFilament / ❓┊help
17mo ago
save component livewire form
FilamentFFilament / ❓┊help
17mo ago