Q: select2 4.0+: How can I fill and access several boxes individually? I have several select2 boxes on my site which I want to access individually and fill individually. Before migrating to select2 4.0 I always used a for each input (hidden) tag which isnt supported any more with select2 4.0+. At the moment my code looks like this:
$(document).ready(function() {
function format(item) { return item.text; };
 var guestarray = <?php echo json_encode($guestarray);?>;
 var datumarray = <?php echo json_encode($datumarray);?>;

$.fn.select2.amd.require([
                          'select2/data/array',
                          'select2/utils'
                        ], function (ArrayData, Utils) {
                          function CustomData ($element, options) {
                            CustomData.__super__.constructor.call(this, $element, options);
                          }

                          Utils.Extend(CustomData, ArrayData);

                          CustomData.prototype.query = function (params, callback) {
                            var data = {
                              results: guestarray
                            };
                            callback(data);
                          };

$(".SELECT").select2({ 
    data:{ results: guestarray, text: 'text' },
    formatSelection: format,
    multiple: true,
    maximumSelectionLength: 3,
    formatResult: format,
    dataAdapter: CustomData
});
                        });

});
This works but I can't indivudalize the select2 boxes meaning some have a different maximumSelectionLength, some have no options at all depending on the var datumarray which is not used at the moment. The HTML looks like this:
<form action="index.php?site=keintrag" method="post">
            <div style="display: inline">
                <select class="SELECT"
                    id="SEL-<?php  echo(date("Hi", $m_time1 )); ?>" style="width: 50%"></select>
                <button name="eintragenvonkunden">Eintragen</button>
            </div>

see that I already use an ID for each select2 box which is based on the time of the day which I want to access later on in php to continue working with the posted data. How can I use that ID in Javascript to fill the select2 individually based on datumarray, set different maximumSelectionLenghts and set different initSelections?
Datumarray looks like this:
$datumarray = array (
            "id" => $rowD['id'],
            "datum" => $rowD['datum'], //date
            "zeit" => $rowD['zeit'], //time (id is based on it)
            "maxinputs" => $rowD['maxinputs'], //maximumSelectionLenghts 
            "k_nrs" => $rowD['k_nrs'], //initselection
    );

