title: Cakephp DropDown with Parent and child
body: <p>To begin here is an example of what I want to achieve using cake-php way to create a combo-box populated from two tables categories and subcategories.</p>
  
  <pre><code>-- Category1
   --- Subcategory1
   --- Subcategory2
   --- ...
  -- Category2
   --- Subcategory1
   --- Subcategory2
   --- ...
  </code></pre>
  
  <p>In my Controller I tried to get list of categories with their subcategories using the code bellow but it didn't work and it just returning the List of Subcategories: </p>
  
  <pre><code>$this-&gt;set('category',($this-&gt;category-&gt;subcategory-&gt;find('list')));
  </code></pre>
  
  <p>Here is the associations I'm using between models: </p>
  
  <h1>category model</h1>
  
  <pre><code>&lt;?php
  
  class category extends AppModel{
  
          public $hasMany=array(
  
                  'subcategory'=&gt;array(
                          'className'=&gt;'subcategories',
  
                      )
  
              );
  
  }
  </code></pre>
  
  <h1>subcategory model</h1>
  
  <pre><code>&lt;?php
  
  class subcategory extends AppModel{
  
  
      public $belongsTo=array(
  
          'category'=&gt;array(
                  'className'=&gt;'categories',
                  'foreignKey'=&gt; 'categories_id'
              )
  
          );
  
  
  }
  </code></pre>
  
  <p>I hope my question is clear and thanks a lot.</p>