© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
jbenavidesv

`statePath` and `visible` nested components not working together

I have something like this:
$array_of_things = ['1', '2', '3'];
$array_of_components = [];
foreach ($array_of_things as $a) {
    array_push(
        $array_of_components,
        Select::make($a)->options([
            'what' => 'what',
            'ever' => 'ever',
            'et' => 'cetera',
        ])->multiple()->visible(function (Get $get) use ($a) {
            return $get('componentX') == $a;
        })
    );
}

// ...

return $form
  ->schema([
    Select::make('componentX')->options([
      '1' => '1',
      '2' => '2',
      '3' => '3'
    ])->dehydrated(false)->live(), // This activates a component from $array_of_components
    Group::make('does_not_matter')->schema($array_of_components)->statePath('someAttribute'),
  ]);
$array_of_things = ['1', '2', '3'];
$array_of_components = [];
foreach ($array_of_things as $a) {
    array_push(
        $array_of_components,
        Select::make($a)->options([
            'what' => 'what',
            'ever' => 'ever',
            'et' => 'cetera',
        ])->multiple()->visible(function (Get $get) use ($a) {
            return $get('componentX') == $a;
        })
    );
}

// ...

return $form
  ->schema([
    Select::make('componentX')->options([
      '1' => '1',
      '2' => '2',
      '3' => '3'
    ])->dehydrated(false)->live(), // This activates a component from $array_of_components
    Group::make('does_not_matter')->schema($array_of_components)->statePath('someAttribute'),
  ]);


In the database, I have a table with a JSON column called
someAttribute
someAttribute
. The idea is that the column saves the JSON dictionary of the components. Something like:

{{'1' : 'what'}, {'3' : 'ever'}}
{{'1' : 'what'}, {'3' : 'ever'}}


But, when using
statePath
statePath
, the components are not showing. When
statePath
statePath
is removed, the components do show, but are not registered as a dictionary and instead only the last modified component get saved.
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

Relation Manager not visible in Nested Resource
FilamentFFilament / ❓┊help
8mo ago
2 form components with same statePath, keyValue broken
FilamentFFilament / ❓┊help
11mo ago
Is there a way to use statePath with nested json-data?
FilamentFFilament / ❓┊help
3y ago
MutateBeforeSave with Standalone Forms, model(), and statePath()
FilamentFFilament / ❓┊help
3y ago