title: Zend_Form_SubForm nested multiple levels deep
body: <p>I'm building a form using Zend_Form and attempting to nest a sub form multiple levels deep. The result I'm after is as follows:</p>
  
  <pre><code>&lt;div id="details"&gt;
      &lt;table class="subForm"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;!-- Element --&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;!-- Element --&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;div id="content"&gt;
      &lt;table class="subForm"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;!-- Element --&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;!-- Element --&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>To do this currently, I have created a sub form with my elements and decorators, attached that to a sub form with decorators (and no elements), which is then attached to a form.</p>
  
  <pre><code>// create sub form container decorators
  public $subFormContainerDecorators = array(
      array('FormElements'),
      array(array('data' =&gt; 'HtmlTag'), array('tag' =&gt; 'div', 
                                              'id'  =&gt; 'details'))
  );
  
  // create sub form decorators
  public $subFormDecorators = array(
      array('FormElements'),
      array(array('data' =&gt; 'HtmlTag'), array('tag'   =&gt; 'table', 
                                              'class' =&gt; 'subForm'))
  );
  
  // create sub form and attach elements
  $details = new Zend_Form_SubForm();
  $details-&gt;setDecorators($this-&gt;subFormDecorators);
  $details-&gt;addElement($name)
          -&gt;addElement($save);
  
  // create container div
  $detailsContainer = new Zend_Form_SubForm();
  $detailsContainer-&gt;setDecorators($this-&gt;subFormContainerDecorators);
  $detailsContainer-&gt;addSubForm($details, 'details');
  
  // attach subform container to main form
  $this-&gt;addSubForm($detailsContainer, 'detailsContainer');
  </code></pre>
  
  <p>This is the only way I can currently seem to acheive the nested level I require. However this would also require me to make decorators for all containers and their sub forms for each sub form set. I cannot see any other way of acheiving this however I'm sure there will be a better way than this.</p>
  
  <p>If anyone can help it would be greatly appreciated.</p>