Skip to content
Advertisement

Select2 multiselect select items from db with Laravel 8

I have a small problem. I have a Select2 multiselect field in my edit form. Now my goal is that my script loads all options and that the correct options are preselected.

I have already tried the whole thing, but so far it has not led to the desired result

Here is my Code

Controller snippet for the multiselect.

JavaScript

edit.blade.php (snippet)

JavaScript

small js code:

JavaScript

I hope someone can help me.

Advertisement

Answer

a sample of solution: with id tags

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement