Search code examples
phplaraveltagsjquery-select2tagging

Select2 Tagging support on Laravel 5.4 not working properly


I created a blog, and put the Tagging system on it, but in the post create page, my tags looks like this: tag bug

This is my HTML code:

    <select name="tags[]" id="select2-multi" class="form-control select2-multi" multiple="multiple">
                @foreach($tags as $tag)
                    <option value="{{ $tag->id }}">{{ $tag->name }}</option>
                @endforeach
            </select>

And this is my script:

    $('#select2-multi').select2({
        tags: true,
        tokenSeparators: [",", " "],
        multiple: true
    })

What can i do to solve this? Helps


Solution

  • It seems like you are missing select2 plugin css file

    Include below css line inside head of page

    <link rel="stylesheet" type="text/css" href="https://select2.github.io/dist/css/select2.min.css">