© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago•
4 replies
Sasa Orasanin

Share state between nested modal

Hello, is it possible to share state between nested modals, my solution almost works but when i try to re-open child modal I cannot get parent one values to set as default:

Forms\Components\Section::make('Heading')
    ->collapsible()
    ->schema([
        Forms\Components\Hidden::make('heading.color'), // sadly I need to have this, otherwise $set('heading.color', $data['color']); would be inside child modal only
        Forms\Components\TextInput::make("heading.text")
            ->hiddenLabel()
            ->required()
            ->columnSpan(5),
        
        Forms\Components\Actions::make([
            Forms\Components\Actions\Action::make('settings')
                ->form([
                    Forms\Components\ColorPicker::make('color')
                        ->default(fn (Get $get) => $get('heading.color')),
                ])
                ->action(function (Set $set, Get $get, $data) {
                    $set('heading.color', $data['color']);
                })
        ])
        ->columnSpan(1)
            
    ])->columns(6),
Forms\Components\Section::make('Heading')
    ->collapsible()
    ->schema([
        Forms\Components\Hidden::make('heading.color'), // sadly I need to have this, otherwise $set('heading.color', $data['color']); would be inside child modal only
        Forms\Components\TextInput::make("heading.text")
            ->hiddenLabel()
            ->required()
            ->columnSpan(5),
        
        Forms\Components\Actions::make([
            Forms\Components\Actions\Action::make('settings')
                ->form([
                    Forms\Components\ColorPicker::make('color')
                        ->default(fn (Get $get) => $get('heading.color')),
                ])
                ->action(function (Set $set, Get $get, $data) {
                    $set('heading.color', $data['color']);
                })
        ])
        ->columnSpan(1)
            
    ])->columns(6),
Solution
This should work, in the action modal, use ->form([...])->mountUsing(function (Form $form, Forms\Get $get) { $form->fill([
'color' => $get('heading.color') ?? 'something'
]);
})
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

Nested modal
FilamentFFilament / ❓┊help
2y ago
Nested Modal Action
FilamentFFilament / ❓┊help
3y ago
Share data between resources
FilamentFFilament / ❓┊help
2y ago
Share records between panels
FilamentFFilament / ❓┊help
2y ago