Select2 library JS/CSS files are not included

Created on 2 May 2025, 5 days ago

Problem/Motivation

After clean installation 2.0.0 module version with composer require 'drupal/select2:^2.0' command module does not work and generates error in browser console.

Steps to reproduce

  1. Install 2.0.0 module version with composer require 'drupal/select2:^2.0' command
  2. In custom form use select2 form element (copy-paste first example from Usage section on module page)
  3. Visit form page: See that select element looks "usual" (without Select2) and in browser console there is errors:
    GET http://dist/css/select2.min.css net::ERR_NAME_NOT_RESOLVED
    GET http://dist/js/select2.min.js net::ERR_NAME_NOT_RESOLVED
    Uncaught TypeError: $(...).select2 is not a function

Proposed resolution

The problem is that on module installation Select2 library was installed in folder with name jquery.select2 not select2 name which expects module in this line: https://git.drupalcode.org/project/select2/-/blob/2.x/select2.module?ref...
It breaks Select2 library JS/CSS files on page including.

I attached to this issue a patch which fixes this issue by renaming select2 library folder name to jquery.select2. After applying this patch module works correctly on my side.

🐛 Bug report
Status

Active

Version

2.0

Component

Field widgets

Created by

🇩🇪Germany Antonnavi Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024