title: Codeigniter + Select2 set default value for use in edit forms
body: <p>To populate my dropdown list I’m using ajax to call a function and get the records I want then I use $.map to change the id and text to the column names I use. </p>
  
  <p>All work perfect but now I’m stuck on how can I give a default value to the dropdown :</p>
  
  <pre><code>$(".js-firme-data-array").select2(  {
          ajax: {
              // The number of milliseconds to wait for the user to stop typing before issuing the ajax request
              delay: 400,
              url: "&lt;?php echo site_url('proiecte/get_firme') ?&gt;",
              dataType: "json",
              cache: "true",
  
              data: function (params) {
                  return {
                  q: params.term, // search term
                  page: params.page,
  
                  };
              },
  
              processResults: function (data) {
                  return {
                      results: $.map(data, function(obj) {
                          return { id: obj.id, text: obj.denumire };
                      })
                  };
              },
          },
      });
  </code></pre>