Search code examples
laravel-backpack

Undefined array key "relation_type"


Im having some issues with a backpack project im doing.

What im trying to do change the way the PermissionsManager displays the check boxes when editing a user.

I have managed to create the custom CRUD files and i know that these files are working as i can edit some of the basic fields to add additional user fields.

The code im using to add the relationship is..

$this->crud->addField(
    [   // relationship
        'name' => 'permission', // the method on your model that defines the relationship
        'type' => "relationship",

        // OPTIONALS:
        // 'label' => "Category",
        // 'attribute' => "title", // attribute on model that is shown to user
        // 'placeholder' => "Select a category", // placeholder for the select2 input
     ]

);

The error i get then i try to access the page is..

Undefined array key "relation_type"

Any ideas on what might be causing this?

thanks!


Solution

  • I think you are getting that error because the relationship name is permissions (plural) and not permission (singular).

    Let me know if that's the case.

    Cheers