How to use select2 in form API drupal 7? Hei please help me using select2 in drupal 7
I'trying to make custom module and form type is select using form API drupal 7

can anyone give an example using select2 module in custom form API
From what I recall, the select2 javascript needs to be #attached to a render node or otherwise included on the page, then the dom content loaded callback used to locate the HTML select items that should be modified. Something like:

function () {
  $('select').select2();
}


See https://select2.github.io/ for examples. Within Drupal, you should really use the Drupal 'behaviours' framework, so that the right thing happens when AJAX and other dynamic loading happens.

There is also the project https://www.drupal.org/project/select2 which may help!