© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
Timster8989

afterStateUpdated in custom component

I have a Filament widget which includes a Livewire component from it's blade. I have a select-field rendering fine and it will update the value. However, I can't get it to run method no matter what I do. Here is the code I've been trying with:

namespace App\Http\Livewire;
...
use Livewire\Component;

class CompanyComparisonForm extends Component implements HasForms
{
    use InteractsWithForms;

    protected $form;
    public $technologies;

    public function formFieldUpdated($propertyName, $value)
    {
        // never gets here
        Log::error('formFieldUpdated2');
    }

    public function render()
    {
        $this->form = $this->makeForm()
            ->schema([
                Select::make('technologies')
                    ->reactive()
                    //->callAfterStateUpdated()
                    ->afterStateUpdated(function ($state) {
                        // never gets here either
                        Log::error('Updating...');
                        // tried these too
                        //$this->formFieldUpdated('technologies', $state);
                        //$this->dispatch('formFieldUpdated', $state);
                    })
                    // these don't make a difference
                    //->live()
                    //->native()
                    ->options([
                        'tailwind' => 'Tailwind CSS',
                        'alpine' => 'Alpine.js',
                        'laravel' => 'Laravel',
                        'livewire' => 'Laravel Livewire',
                    ])
            ])

            // this also doesn't change whether it's enabled or not
            ->live();
        return view('livewire.company-comparison-form');
    }
}`
namespace App\Http\Livewire;
...
use Livewire\Component;

class CompanyComparisonForm extends Component implements HasForms
{
    use InteractsWithForms;

    protected $form;
    public $technologies;

    public function formFieldUpdated($propertyName, $value)
    {
        // never gets here
        Log::error('formFieldUpdated2');
    }

    public function render()
    {
        $this->form = $this->makeForm()
            ->schema([
                Select::make('technologies')
                    ->reactive()
                    //->callAfterStateUpdated()
                    ->afterStateUpdated(function ($state) {
                        // never gets here either
                        Log::error('Updating...');
                        // tried these too
                        //$this->formFieldUpdated('technologies', $state);
                        //$this->dispatch('formFieldUpdated', $state);
                    })
                    // these don't make a difference
                    //->live()
                    //->native()
                    ->options([
                        'tailwind' => 'Tailwind CSS',
                        'alpine' => 'Alpine.js',
                        'laravel' => 'Laravel',
                        'livewire' => 'Laravel Livewire',
                    ])
            ])

            // this also doesn't change whether it's enabled or not
            ->live();
        return view('livewire.company-comparison-form');
    }
}`


The view has nothing else than this:
<div>
    {{$technologies}}
    {{ $this->form }}
</div>
<div>
    {{$technologies}}
    {{ $this->form }}
</div>


Any help here would be greatly appreciated (and yes, I've been reading documentation and other posts back and forth)!
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

afterStateUpdated() not running on custom component
FilamentFFilament / ❓┊help
3y ago
afterStateUpdated in toggle in a custom component not firering
FilamentFFilament / ❓┊help
14mo ago
Using filament components in custom livewire component
FilamentFFilament / ❓┊help
3y ago
watchout when afterStateUpdated from another component
FilamentFFilament / ❓┊help
13mo ago