Skip to content

hard to find : how to setup a morph relationship? #501

@realtebo

Description

@realtebo

I have a movements table and the Movement model class

This table has fields for morphing

  • coinable_type
  • coinable_id

This model class has relationship

public function coinable(): MorphTo
    {
        return $this->morphTo();
    }

Then I am trying to add the morph related fields using this in the setupCreateOperation

CRUD::field([
            'type' => 'relationship',
            'name' => 'coinable',
        ]);

I got the error

Undefined array key "morphOptions"

From \vendor\backpack\pro\resources\views\fields\relationship\morphTo.blade.php: 21

I am in the page where the relationship field is documented.

I kindly suggest to add a backlink to

https://backpackforlaravel.com/docs/6.x/crud-how-to#morphto-n-1-relationship

or the upper

https://backpackforlaravel.com/docs/6.x/crud-how-to#what-field-should-i-use-for-a-relationship-1

because until now we didn't know the existence of this FAQ.

I suggest before or after this point

image

to add a link to point developers to the relevant faq

The actual link points to https://backpackforlaravel.com/docs/6.x/crud-fields#optional-attributes-for-fields-containing-related-entries

And this is absolutely needed.
But a second link pointing to faq about morph will be usefull..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions