nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

Bug: Flexible content not working with Polymorphic Relationships

Open Sauruz opened this issue 1 year ago • 0 comments

This module is really great. However, I found a bug. I've got Flexible content on my model Enrichments which looks like this:

class Enrichment extends Model {

    protected $casts = [
        'content' => FlexibleCast::class
    ];

    public function enrichable()
    {
        return $this->morphTo();
    }
} 

The table structure of enrichments looks like this:

id, enrichable_id, enrichable_type, intro, content

This model works great with the corresponding Nova resource. However, when I use the Enrichment resource in another Nova resource like this:

MorphOne::make('Enrichment'),

Saving flexible content doesn't work when you edit or update the resource. It will give the following error: Unable to parse incoming Flexible content, data should be an array.

Sauruz avatar Feb 09 '23 11:02 Sauruz