RichEditor field on a hasOne relation array-cast attribute

Not sure if this a common scenario, but I can't save data to a form with a hasOne relation having itself a json/array attribute. This is the setup:

class Location extends Model 
{
    public function hotel(): HasOne
    {
        return $this->hasOne(Hotel::class);
    }
}

class Hotel extends Model 
{
    protected function casts(): array
    {
        return [
            'hotel_data' => 'array',
        ];
    }
}


On my LocationResource form I have the following schema:

Grid::make()
    ->relationship('hotel')
    ->schema([
        TextInput::make('name'),
        Textarea::make("hotel_data.test");    
    ])


This works as expected. It creates, saves and shows the data. But when I use a RichEditor instead of a Textarea:

Grid::make()
    ->relationship('hotel')
    ->schema([
        TextInput::make('name'),
        RichEditor::make("hotel_data.test");    
    ])


I can't save it and I am getting this error:

Filament\Forms\Components\RichEditor::Filament\Forms\Components\{closure}(): Argument #2 ($rawState) must be of type ?array, string given, called in


Any ideas why?`
Was this page helpful?