Webform and Module Select2-Module library path

Created on 1 December 2018, over 5 years ago
Updated 21 March 2024, 3 months ago

Hello,

in my Drupal 8 installation I use the select2 Module β†’ for node fields and this module --> webform.

Select2 module requires the select2 library at the path "drupal-root/library/select2" and webform requires it at "drupal-root//libraries/jquery.select2".

I would appreciate it, if webform could change the required path to "drupal-root/library/select2" to use one library multiple times :)

thx

✨ Feature request
Status

Fixed

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany dercheffe Sersheim, Germany

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ͺπŸ‡ΈSpain cesarmsfelipe

    Hi everyone,

    I encountered an issue where both the select2 and webform Drupal 9 modules required the same JavaScript library (jquery.select2), but it was only being fetched and stored for the webform module in web/libraries/jquery.select2. The select2 module, however, was expecting this library to be in web/libraries/select2, which led to a dependency resolution problem.

    To solve this, I implemented a solution using a symbolic link, created by a script executed via Composer's event hooks. This approach ensures that the select2 module can correctly locate and use the jquery.select2 library without needing to duplicate the library files.

    Here's the script that creates the symbolic link (scripts/fix_select2_dependency.php):

    <?php

    $source = __DIR__ . '/../web/libraries/jquery.select2';
    $destination = __DIR__ . '/../web/libraries/select2';

    // Check if the destination directory exists, create it if it doesn't
    if (!file_exists(dirname($destination))) {
    mkdir(dirname($destination), 0755, true);
    }

    // Create a symbolic link if it does not already exist
    if (!is_link($destination)) {
    symlink($source, $destination);
    echo "Symbolic link created: $destination -> $source\n";
    }

    And these are the modifications to composer.json to invoke the script after install and update events:

    "scripts": {
    "post-install-cmd": [
    "php scripts/fix_select2_dependency.php"
    ],
    "post-update-cmd": [
    "php scripts/fix_select2_dependency.php"
    ]
    }

    I hope this solution helps anyone facing a similar issue. Feel free to adjust the script paths according to your project's directory structure.

Production build 0.69.0 2024