You are here

README.txt in Select 2 7

Drupal select2 module:
------------------------
Maintainers:
  Andrey G Polyakov (http://drupal.org/user/1200780)
Requires - Drupal 7, Libraries API (7.x-2.x), jQuery Update 
License - GPL (see LICENSE)


Overview:
--------
Select2 is a jQuery (1.8.2+) based replacement for select boxes.
It supports searching, remote data sets, and infinite scrolling of results.
This module allows for integration of Select2 into Drupal.
The jQuery library is a part of Drupal since version 5+.

* jQuery - http://jquery.com/
* Select2 - http://ivaynberg.github.io/select2/


Features:
---------

The Select2 module:

* Provide function for using Select2 plugin by Drupal Form API

The Colorbox plugin:

* Enhancing native selects with search.
* Enhancing native selects with a better multi-select interface.
* Loading data from JavaScript: easily load items via ajax and have them searchable.
* Nesting optgroups: native selects only support one level of nested. Select2 does not have this restriction.
* Tagging: ability to add new items on the fly.
* Working with large, remote datasets: ability to partially load a dataset based on the search term.
* Paging of large datasets: easy support for loading more pages when the results are scrolled to the end.
* Templating: support for custom rendering of results and selections.


Installation:
------------
1. Download and unpack the Libraries module (2.x) directory in your modules folder
   (this will usually be "modules/").
   Link: http://drupal.org/project/libraries
2. Download and unpack jQuery Update module - you must use jQuery Update module version
   that can set jQuery version for admin pages - 7.x-2.x-dev at this moment (01-01-2014). 
   Use 1.8 or higher version of jQuery.
2. Download and unpack the Select2 module directory in your modules folder
   (this will usually be "modules/").
3. Download and unpack the Select2 plugin (3.4.5+) in "libraries".
    Make sure the path to the plugin file becomes:
    "libraries/select2/select2.js"
   Link: https://github.com/ivaynberg/select2/tags
4. Go to "Administer" -> "Modules" and enable the Select2 module.


Configuration:
-------------
Go to "Configuration" -> "User Interface" -> "Select2" to find
all the configuration options.


Using Select2 in Forms API:
----------------------------------------
For attaching Select2 plugin with custom properties to form element
you must define '#select2' key as array for form element

  'products_categories' => array(
    '#title' => t('Element title'),
    '#type'     => 'select',
    '#options' => array(),
    '#empty_option' => t('Select element'),
    '#multiple'     => 1,
    '#select2' => array(),
  );

You can define all (except value as function) properties of Select2 plugin
(look at http://ivaynberg.github.io/select2/#documentation), in "#select2" array
of element: array key - property name, value - property value. 

  'products_categories' => array(
    '#title' => t('Element title'),
    '#type'     => 'select',
    '#options' => array(),
    '#empty_option' => t('Select element'),
    '#multiple'     => 1,
    '#select2' => array(
      'width' => 300,
      'allowClear' => true,
      'minimumInputLength' => 1,
      ...
    ),
  );

For some fields (if field type supported by module) you can define Select2 properties on field settings page.


  

File

README.txt
View source
  1. Drupal select2 module:
  2. ------------------------
  3. Maintainers:
  4. Andrey G Polyakov (http://drupal.org/user/1200780)
  5. Requires - Drupal 7, Libraries API (7.x-2.x), jQuery Update
  6. License - GPL (see LICENSE)
  7. Overview:
  8. --------
  9. Select2 is a jQuery (1.8.2+) based replacement for select boxes.
  10. It supports searching, remote data sets, and infinite scrolling of results.
  11. This module allows for integration of Select2 into Drupal.
  12. The jQuery library is a part of Drupal since version 5+.
  13. * jQuery - http://jquery.com/
  14. * Select2 - http://ivaynberg.github.io/select2/
  15. Features:
  16. ---------
  17. The Select2 module:
  18. * Provide function for using Select2 plugin by Drupal Form API
  19. The Colorbox plugin:
  20. * Enhancing native selects with search.
  21. * Enhancing native selects with a better multi-select interface.
  22. * Loading data from JavaScript: easily load items via ajax and have them searchable.
  23. * Nesting optgroups: native selects only support one level of nested. Select2 does not have this restriction.
  24. * Tagging: ability to add new items on the fly.
  25. * Working with large, remote datasets: ability to partially load a dataset based on the search term.
  26. * Paging of large datasets: easy support for loading more pages when the results are scrolled to the end.
  27. * Templating: support for custom rendering of results and selections.
  28. Installation:
  29. ------------
  30. 1. Download and unpack the Libraries module (2.x) directory in your modules folder
  31. (this will usually be "modules/").
  32. Link: http://drupal.org/project/libraries
  33. 2. Download and unpack jQuery Update module - you must use jQuery Update module version
  34. that can set jQuery version for admin pages - 7.x-2.x-dev at this moment (01-01-2014).
  35. Use 1.8 or higher version of jQuery.
  36. 2. Download and unpack the Select2 module directory in your modules folder
  37. (this will usually be "modules/").
  38. 3. Download and unpack the Select2 plugin (3.4.5+) in "libraries".
  39. Make sure the path to the plugin file becomes:
  40. "libraries/select2/select2.js"
  41. Link: https://github.com/ivaynberg/select2/tags
  42. 4. Go to "Administer" -> "Modules" and enable the Select2 module.
  43. Configuration:
  44. -------------
  45. Go to "Configuration" -> "User Interface" -> "Select2" to find
  46. all the configuration options.
  47. Using Select2 in Forms API:
  48. ----------------------------------------
  49. For attaching Select2 plugin with custom properties to form element
  50. you must define '#select2' key as array for form element
  51. 'products_categories' => array(
  52. '#title' => t('Element title'),
  53. '#type' => 'select',
  54. '#options' => array(),
  55. '#empty_option' => t('Select element'),
  56. '#multiple' => 1,
  57. '#select2' => array(),
  58. );
  59. You can define all (except value as function) properties of Select2 plugin
  60. (look at http://ivaynberg.github.io/select2/#documentation), in "#select2" array
  61. of element: array key - property name, value - property value.
  62. 'products_categories' => array(
  63. '#title' => t('Element title'),
  64. '#type' => 'select',
  65. '#options' => array(),
  66. '#empty_option' => t('Select element'),
  67. '#multiple' => 1,
  68. '#select2' => array(
  69. 'width' => 300,
  70. 'allowClear' => true,
  71. 'minimumInputLength' => 1,
  72. ...
  73. ),
  74. );
  75. For some fields (if field type supported by module) you can define Select2 properties on field settings page.