title: Creating dropdown list from related table yii
body: <p>I have two tables: <em>product</em> and <em>product_type</em> (related to the models resp. Product and Product_type): </p>
  
  <pre><code>product : product_id, product_type_id, name, etc...
  product_type : product_type_id, name, desc, etc...
  </code></pre>
  
  <p>Both are related with key "product_type_id".</p>
  
  <p>I have created the crud for both tables using gii crud generator. Now on Product form page I want to display the listing of all product_type name in dropdown field using Yii ActiveRecord. I have added this line in <em>views/product/_form.php</em> script:</p>
  
  <pre><code>&lt;?php
      $list = CHtml::listData(ProductType::model()-&gt;findAll(array('order' =&gt; 'product_type_name')), 'id', 'id');
      echo $form-&gt;dropDownList($model, 'product_type_id', $list);
  ?&gt;
  </code></pre>
  
  <p>But it's showing blank dropdown field :(</p>
  
  <p>How can I do this?</p>