Create action with relation throws error
Sorry for the vague title
I have the following action
When I click on the button, I get the following error
This is the exact same form I use in the
UserResource
and it works when creating a new user, but for some reason doesn't work when doing it outside the resource. I tried adding
and some other things but nothing worked. What am I doing wrong?Solution:Jump to solution
Yeap, everything is setup correctly. The form works when used in the
UserResource
but since I was trying to create the user object from another resource, it would get messed up. Here's the final solution that worked for me
```php
Actions\CreateAction::make('createLoginDetails')
->label(__('Create login details'))
->hidden(fn () => $this->getRecord()->user !== null)...2 Replies
Seems to me that the relationship
roles
does not exist in your model, are you sure that's the correct name?Solution
Yeap, everything is setup correctly. The form works when used in the
UserResource
but since I was trying to create the user object from another resource, it would get messed up. Here's the final solution that worked for me
Essentially, I have a contact record that is linked to a User
- users are only used for authentication purposes