whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
780 stars 229 forks source link

Bug: Flexible content not working with Polymorphic Relationships #435

Open Sauruz opened 1 year ago

Sauruz commented 1 year ago

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.