title: How to make dropdown list in Yii2 with ArrayHelper
body: <p>I want to make dropdownlist <strong>from single record</strong>, I have two table like this:</p>
  
  <p><a href="https://i.stack.imgur.com/PTSTL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PTSTL.png" alt="the tables"></a></p>
  
  <p>Column <code>prodi_pilihan_1_id</code> and <code>prodi_pilihan_2_id</code> <strong>referenced</strong> from <code>prodi_penerima</code> table.</p>
  
  <p>I want make dropdown for column <code>prodi_pilihan_1_id</code> and <code>prodi_pilihan_2_id</code> but the option text is from <code>prodi_penerima</code> that is <code>nama_prodi_penerima</code> so the dropdown be like this:</p>
  
  <pre><code>&lt;select&gt;
      &lt;option value= '2'&gt; BBB  &lt;/option&gt;
      &lt;option value= '4'&gt; DDD  &lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>So suggest from <a href="https://stackoverflow.com/questions/50764216/how-to-make-dropdown-in-yii2-from-one-record">How to make dropdown in Yii2 from one record</a>, I created controller like this:</p>
  
  <pre><code> $model4 = Pendaftar::find()
    -&gt;select(['pro1.id_prodi_penerima as id_prodi_pilihan_1','pro1.nama_prodi_penerima as prodi_pilihan_1','pro2.id_prodi_penerima as id_prodi_pilihan_2','pro2.nama_prodi_penerima as prodi_pilihan_2'])
    -&gt;from('pendaftar') 
    -&gt;leftJoin('prodi_penerima as pro1', 'pro1.id_prodi_penerima=pendaftar.prodi_pilihan_1')
    -&gt;leftJoin('prodi_penerima as pro2', 'pro2.id_prodi_penerima=pendaftar.prodi_pilihan_2')
    -&gt;andWhere(['=','id_user_pendaftar',$id])
    -&gt;asArray()
    -&gt;One();
     $rows=\yii\helpers\ArrayHelper::map(array_filter([$model4['prodi_pilihan_1'],$model4['prodi_pilihan_2']]),function($item){
          return $item;
      },function($item){
          return $item;
      });
   //return $this-&gt;render('lulus_ujian', ['rows' =&gt; $rows]);
      return $this-&gt;renderAjax('lulus_ujian', [
          'model' =&gt; $this-&gt;findModel($id),
          'rows' =&gt; $rows,
      ]);
  </code></pre>
  
  <p>I render that into the view and then into the form, the form is like this:</p>
  
  <pre><code>&lt;?php $form = ActiveForm::begin(); ?&gt;
  &lt;?= $form-&gt;field($model, 'status_lulus_tes_pendaftar')-&gt;dropDownList([ 'yes' =&gt; 'Yes', 'no' =&gt; 'No', ], ['prompt' =&gt; '']) ?&gt;
  &lt;?= $form-&gt;field($model, 'prodi_lulus')-&gt;dropDownList($rows, ['prompt' =&gt; '']) ?&gt;
      &lt;?= $form-&gt;field($model, 'ket_lulus_ujian')-&gt;textarea(['rows' =&gt; '6']) ?&gt;
  &lt;div class="form-group"&gt;
      &lt;?= Html::submitButton('Save', ['class' =&gt; 'btn btn-danger']) ?&gt;
  &lt;/div&gt;
  
  &lt;?php ActiveForm::end(); ?&gt;  
  </code></pre>
  
  <p></p>
  
  <p>The dropdown is working, <strong>but the value and the option is having the same value</strong>:</p>
  
  <pre><code>&lt;select&gt;
      &lt;option value= 'BBB'&gt; BBB  &lt;/option&gt;
      &lt;option value= 'DDD'&gt; DDD  &lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I want save the model where the option value is <code>id_prodi_penerima</code>.
  What I must do so the option value is 2 and 4 like this:</p>
  
  <pre><code>&lt;select&gt;
      &lt;option value= '2'&gt; BBB  &lt;/option&gt;
      &lt;option value= '4'&gt; DDD  &lt;/option&gt;
  &lt;/select&gt;
  </code></pre>