Relationship is empty after save

After saving a form that contains a relationship the relationship section is empty.
The data is correctly stored and fetched but filament clear the data.ralationship node by filling all the components states with null values.

I've tried to trace the issue out and I've seen that:
EditRecord.php call the $this->form->getState().

this method is the responsible of the data object to be overwritten.
More specifically is the loadStateFromRelationship() that when run the data is not somehow re-fetched and null is loaded instead. $this->fillStateWithNull() is called inside the component.

Why the data is not loaded correctly after the save?

Below the form schema:

public static function form(Form $form): Form
{
    return $form
        ->schema([
            Forms\Components\TextInput::make('name')
                ->label('Name')
                ->required(),

            Forms\Components\Toggle::make('hasTemplate')
                ->label('Create template')
                ->live(true),

            Forms\Components\Group::make()
                ->relationship('template', fn(Forms\Get $get) => $get('hasTemplate'))
                ->schema([ 
                    Forms\Components\Group::make()
                        ->visible(fn(Forms\Get $get) => $get('../hasTemplate'))
                        ->schema([
                            Forms\Components\Select::make('facility_id')
                                ->label('Facility')
                                ->relationship(
                                    'facility',
                                    'Name',
                                    fn(Builder $query) => $query->available()
                                ),                                                
                        ]),
                ]),
        ]);
}
Was this page helpful?