Bug in select2 advanced when adding custom class name to container?

Support General Bug in select2 advanced when adding custom class name to container?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44772
    AishwaryaAishwarya
    Participant

    I am populating a select2 advanced field using the below code but it just shows normal select instead of select2 with search box. When removing the "containerCssClass", it works.

    array(
                    'name'            => 'Select Language',
                    'id'              => 'language',
                    'type'            => 'select_advanced',
                    'ajax'       => true,
                    'options'         => [
                        'java'       => 'Java',
                        'javascript' => 'JavaScript',
                        'php'        => 'PHP',
                        'kotlin'     => 'Kotlin',
                        'swift'      => 'Swift',
                        'javha'       => 'Java',
                        'javhascript' => 'JavaScript',
                        'pfhp'        => 'PHP',
                        'kottlin'     => 'Kotlin',
                        'swiyjft'      => 'Swift',
                    ],
                    'placeholder'     => 'Select an Item',
                    'js_options'      => [
                        'containerCssClass' => 'my-custom-class',
                    ],
                ),

    this works

    array(
                    'name'            => 'Select Language',
                    'id'              => 'language',
                    'type'            => 'select_advanced',
                    'ajax'       => true,
                    'options'         => [
                        'java'       => 'Java',
                        'javascript' => 'JavaScript',
                        'php'        => 'PHP',
                        'kotlin'     => 'Kotlin',
                        'swift'      => 'Swift',
                        'javha'       => 'Java',
                        'javhascript' => 'JavaScript',
                        'pfhp'        => 'PHP',
                        'kottlin'     => 'Kotlin',
                        'swiyjft'      => 'Swift',
                    ],
                    'placeholder'     => 'Select an Item',
                ),
    #44774
    PeterPeter
    Moderator

    Hello,

    There isn't an option containerCssClass in the Select2 documentation https://select2.org/configuration/options-api

    Please correct option name and check this issue again.

    #44796
    AishwaryaAishwarya
    Participant

    Hi Peter,

    Thanks for the clarification.

    I got it. I didn't compared it with select2.org options but just copied it from metabox documentation https://docs.metabox.io/fields/select-advanced/

    Anyway, I will check it out by changing the option name.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.