© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Quadrubo

Static property state does not persist

I don't know if this is a general PHP thing or has got to do with the way Filament works or I'm doing something wrong but somehow the state doesn't persist.
I'm setting a static property in the
getSearchResultsUsing()
getSearchResultsUsing()
function and afterwards retrieve that property in the
afterStateUpdated()
afterStateUpdated()
function but it errors with the message "must not be accessed before initialization".

Forms\Components\Select::make('title')
    ->required()
    ->searchable()
    ->reactive()
    ->getSearchResultsUsing(function (string $search) {
        $tmdb = new TMDBConnector;
        $request = new SearchMovieRequest($search);

        $response = $tmdb->send($request);

        $body = $response->body();
        $decodedBody = $response->json();

        $results = collect($decodedBody['results']);

        static::$searchResults = $results;

        return $results->pluck('title', 'id');
    })
    ->afterStateUpdated(function (Closure $set, $state) {
        dd(static::$searchResults);
    })
Forms\Components\Select::make('title')
    ->required()
    ->searchable()
    ->reactive()
    ->getSearchResultsUsing(function (string $search) {
        $tmdb = new TMDBConnector;
        $request = new SearchMovieRequest($search);

        $response = $tmdb->send($request);

        $body = $response->body();
        $decodedBody = $response->json();

        $results = collect($decodedBody['results']);

        static::$searchResults = $results;

        return $results->pluck('title', 'id');
    })
    ->afterStateUpdated(function (Closure $set, $state) {
        dd(static::$searchResults);
    })


What is happening here? What can I do to save data between the functions or am I doing something completely wrong conceptually. Thanks in advance!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Reactive Field does not persist data
FilamentFFilament / ❓┊help
2y ago
Persist toggleable column state between sessions
FilamentFFilament / ❓┊help
3y ago
Saving Optional Relationship to db does not persist
FilamentFFilament / ❓┊help
2y ago
Typed static property Error after upgrading to V3
FilamentFFilament / ❓┊help
3y ago