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),
Solution
This should work, in the action modal, use ->form([...])->mountUsing(function (Form $form, Forms\Get $get) { $form->fill([
'color' => $get('heading.color') ?? 'something'
]);
})
Was this page helpful?