title: Select2 dropdown with dynamic name and image in yii2
body: <p>I am working on yii2. </p>
  
  <p>I have form with many fields. </p>
  
  <p>I have one field that which has name and image. </p>
  
  <p>I want to display that with select2 dropdown with name and image. Name is coming but how to display image in that dropdown.</p>
  
  <p><strong>Yii view file code :</strong></p>
  
  <pre><code>&lt;?php $form = ActiveForm::begin(); ?&gt;
         &lt;div class="col-xs-6 col-md-5"&gt;
            &lt;?= $form-&gt;field($model,'db_fieldname')-&gt;dropDownList(['0'=&gt;'Select category']
            + ArrayHelper::map(Category::find()-&gt;all(),'id','name'),
            ['multiple'=&gt;'multiple']) ?&gt;
         &lt;/div&gt;
  &lt;?php ActiveForm::end(); ?&gt;
  </code></pre>
  
  <p><strong>I have wrote JS :</strong>
  At the end of my view file </p>
  
  <pre><code>&lt;?php
      $this-&gt;registerJs('$("select").select2( templateResult: format);');
   ?&gt;
  </code></pre>
  
  <p><strong>Now according to above code please guide me how to display image in dropdown.</strong></p>