title: How do I group checkboxes by parent with Active Admin (formatastic)
body: <p>This is the category model. A category can belong to another category.</p>
  
  <pre><code>class Category &lt; ActiveRecord::Base
    attr_accessible :title, :parent_id
  
    has_and_belongs_to_many :products, :join_table =&gt; :products_categories
  
    belongs_to :parent, :foreign_key =&gt; "parent_id", :class_name =&gt; "Category"
    has_many :categories, :foreign_key =&gt; "parent_id", :class_name =&gt; "Category"
  end
  </code></pre>
  
  <p>This is the product model:</p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
    attr_accessible :comment, location_id, :category_ids
    has_and_belongs_to_many :categories, :join_table =&gt; :products_categories
    belongs_to :location
  end
  </code></pre>
  
  <p><strong>In the Active Admin form for a product I want to hierarchically order the checkboxes based on their parent_id e.g.</strong></p>
  
  <ul>
  <li>Category 1 [ ]
  <ul>
  <li>Category 2 [ ]</li>
  <li>Category 3 [ ]</li>
  </ul></li>
  <li>Category 6 [ ]
  <ul>
  <li>Category 4 [ ]</li>
  </ul></li>
  <li>Category 5 [ ]</li>
  <li>Category 7 [ ]</li>
  </ul>
  
  <p>Below is as far as I've got with the form:</p>
  
  <pre><code>ActiveAdmin.register Product do
      form do |f|
        f.inputs "Product" do
        f.input :comment
        f.input :categories, :as =&gt; :check_boxes
        f.input :location
      end
      f.buttons
    end
  end
  </code></pre>
  
  <p>Currently the form pulls in the checkboxes and saves the data correctly but I'm not sure where to begin with grouping them. I looked through the documentation but couldn't see anything obvious.</p>