kartik-v / yii2-widget-select2

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).
http://demos.krajee.com/widget-details/select2
Other
323 stars 145 forks source link

How to add data- attribute in each option tag ? #235

Closed faizalami closed 6 years ago

faizalami commented 6 years ago

Prerequisites

Steps to reproduce the issue

I need to use data- attribute for use another jQuery plugin, the plugin request data attribute for each options for example : <option data-name="Name" data-address="Address" value="1">Person Name</option>

Expected behavior and actual behavior

I read the documentation and I can't find option for do that.

Environment

Browsers

Operating System

Libraries

Isolating the problem

kartik-v commented 6 years ago

Set Select2::options['options'] as an associative array ...

for example check the second example in the Select2 documentation - advanced example demo - it shows how you can set disabled attribute for each option... you can similarly set other HTML attributes.

faizalami commented 6 years ago

Okay Thanks a lot