docs icon indicating copy to clipboard operation
docs copied to clipboard

hard to find : how to setup a morph relationship?

Open realtebo opened this issue 10 months ago • 0 comments

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..

realtebo avatar Aug 23 '23 08:08 realtebo