Issue with Populating Polymorphic Fields in Nested Form for SEO Data

Hi there,

I need assistance with editing SEO fields in the backend of a CMS platform. We have these SEO fields stored in a morphOne relationship with the SeoData model. This approach helps us attach a variety of SEO fields to different models and plugins efficiently, avoiding the need to duplicate columns across our models due to our platform’s setup.

Currently, I am attempting to edit these fields using a nested form. However, I’m facing an issue: the polymorphic fields seoable_type and seoable_id are not being populated, which causes a MySQL error.

Below is my current nestedform configuration:

seo_data:
        label: 'SEO Data'
        type: nestedform
        form:
            fields:
                data[meta_title]:
                    label: 'SEO Titel'
                    type: text
                    span: left

                data[meta_description]:
                    label: 'SEO Beschrijving'
                    type: textarea
                    span: right

Could you please advise on how to ensure these polymorphic fields (seoable_type and seoable_id) are correctly populated when using the nested form?

Thank you for your help!

Hey @gldrenthe89

It’s challenging to know what the issue might be. To take a guess, have you got default => true specified on the relationship definition? This will ensure a default model (with _type and _id fields populated) is created for new models.

Hi,

default => true is not something documented in the link you provided. At least i cant find it. I also tried adding it to the relation definition. But same issue occurs.