whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
787 stars 234 forks source link

Casting issue with actionable #285

Open Broutard opened 3 years ago

Broutard commented 3 years ago

Another issue relative to https://github.com/whitecube/nova-flexible-content/issues/275

On a flexible field, with no specific casting (or with a Whitecube\NovaFlexibleContent\Value\FlexibleCast cast),
when we use the Nova Actionable trait on a model, the Flexible field value is considered as dirty even without modification.

This seems to be due to HasFlexible::cast() which returns a Collection while Model::getOriginal() returns the raw value :

$model->getDirty()

[
   'flexible' => Illuminate\Support\Collection { ... }
]

$model->getOriginal() ... should also return a Collection unlike getRawOriginal()

[
   'flexible' => [{"layout":"register","key":"0e2e3d51b9d39181","attributes": ... ]}
]

If the flexible field is casted as "collection", it works.