Yes, but only when you are initially creating it.
The id
and text
properties are required on each object, and these are the properties that Select2 uses for the internal data objects. Any additional paramters passed in with data objects will be included on the data objects that Select2 exposes.
Because Select2 falls back to an <optgroup>
when creating nested options, only a single level of nesting can be supported.
<option>
tags being created?
The data
option is a shortcut that Select2 provides which allows you to load options into your select
from a data array.
id
for their unique identifiers, what can I do?
You can re-map your identifier before passing it to Select2.
text
for the text that needs to be displayed
These can also be re-mapped.