Edit Form multiselect with Spatie laravel-Permission - Struggling to get it to work
Continuing on from Chat, where I can't get the default relationship method to work on the select I've got this at least opening up with the right roles already assigned - but searching for and selecting any others the names change to id numbers and clicking submit does not save any changes.
This
4 Replies
you need to remove the 'roles' array key from the fill()
and make sure you define
getFormModel()
to return $this->user
you should try ->relationship('roles', 'name')
instead of ->getSearchResultsUsing()
and ->getOptionLabelUsing()
And using is just producing that error from earlier.
I'm guessing I'm doing something fundamentally wrong or it's specific to the spatie package.
Works on the table, for example using roles.name, I'll keep fiddling.
I think this might be the problem: should be User at the end, not sure where I got string from.