title: Adding Docusign Template array into REST Header
body: <p>So I'm back again. My problem is this:
  I have an array of Docusign Templates from checkboxes in a Codeigniter view:</p>
  
  <pre><code>&lt;?php
      echo form_open('create_envelope');
      foreach ($response["envelopeTemplates"] as $envelopeTemplate) { ?&gt;
          &lt;li&gt;&lt;?php echo form_checkbox('templatearray[]', $envelopeTemplate["templateId"], FALSE), $envelopeTemplate["name"]; ?&gt;&lt;/li&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>What I'm trying to do is add the templates to our REST Header request:</p>
  
  <pre><code>$data = array(
      "accountId" =&gt; $accountId,
      "emailSubject" =&gt; "Hello World!",
      "emailBlurb" =&gt; "This comes from PHP",
      "templateId" =&gt; "ID from template array here",
      "templateRoles" =&gt; array(
          array(
              "tabs" =&gt; array(
              "textTabs" =&gt; array (
                  array (
                      "tabLabel" =&gt; "lic_num", 
                      "value" =&gt; "$license_number"
                  ),
                  array (
                      "tabLabel" =&gt; "ubi_num",
                      "value" =&gt; "$ubi_number"
                  ),
                  array (
                      "tabLabel" =&gt; "tra_nam",
                      "value" =&gt; "$trade_name"
                  )
               )
            ),
            "email" =&gt; "$applicant_email",
            "name" =&gt; "$applicant_name",
            "roleName" =&gt; "Applicant"
            ) 
       ),
      "status" =&gt; "sent"
  );
  </code></pre>
  
  <p>Is this possible?</p>
  
  <p><strong>EDIT:</strong> So I got it to work using loops to get my data in the request, but I'm running into an interesting problem. If I put one or two templates in the envelope, it sends fine. If I put more than two in, it duplicates the templates. Here is my code for the complicated loops:</p>
  
  <pre><code>$compTempArray = array();
  $applicant_name = $this-&gt;input-&gt;post("applicant_name");
  $applicant_email = $this-&gt;input-&gt;post("applicant_email");
  $license_number = $this-&gt;input-&gt;post("license_number");
  $ubi_number = $this-&gt;input-&gt;post("ubi_number");
  $trade_name = $this-&gt;input-&gt;post("trade_name");
  foreach($hello as $key =&gt; $value) {
      if(sizeof($hello) &gt; 1) {
          for($i = 1; $i &lt; sizeof($hello); $i++) {
              $compTempArray[] = array("serverTemplates" =&gt; array(
                  array(
                      "sequence" =&gt; $i,
                      "templateId" =&gt; $value
                  )
              ),
              "inlineTemplates" =&gt; array(
                  array(
                      "sequence" =&gt; $i,
                      "recipients" =&gt; array(
                          "signers" =&gt; array(
                              array(
                                  "tabs" =&gt; array(
                                              "textTabs" =&gt; array (
                                                              array ("tabLabel" =&gt; "lic_num", "value" =&gt; $license_number),
                                                              array ("tabLabel" =&gt; "ubi_num", "value" =&gt; $ubi_number),
                                                              array ("tabLabel" =&gt; "tra_nam", "value" =&gt; $trade_name)
                                              )
                                  ),
                                  "email" =&gt; "*********@*****.com",
                                  "name" =&gt; $applicant_name,
                                  "recipientId" =&gt; "1",
                                  "roleName" =&gt; "Applicant"
                              ),
                          )
                      )
                  )
              ));
  
          }
          $data = array("accountId" =&gt; $accountId,
                        "emailSubject" =&gt; "Hello World!",
                        "emailBlurb" =&gt; "This comes from PHP",
                        "compositeTemplates" =&gt; $compTempArray,
                        "status" =&gt; "sent");
          } else {
              $data = array("accountId" =&gt; $accountId,
                        "emailSubject" =&gt; "Hello World!",
                        "emailBlurb" =&gt; "This comes from PHP",
                        "templateId" =&gt; "$value",
                        "templateRoles" =&gt; array(
                                              array(
                                                  "tabs" =&gt; array(
                                                              "textTabs" =&gt; array (
                                                                              array ("tabLabel" =&gt; "lic_num", "value" =&gt; $license_number),
                                                                              array ("tabLabel" =&gt; "ubi_num", "value" =&gt; $ubi_number),
                                                                              array ("tabLabel" =&gt; "tra_nam", "value" =&gt; $trade_name)
                                                              )
                                                  ),
                                                  "email" =&gt; "*********@*****.com",
                                                  "name" =&gt; $applicant_name,
                                                  "roleName" =&gt; "Applicant"
  
                                              )   
                                           ),
                      "status" =&gt; "sent"); 
          }
      }
  </code></pre>
  
  <p>Any idea why it would do this?</p>
  
  <p><strong>NEW EDIT:</strong> Update on this weirdness: one to two - one copy of each template, three - it doubles the amount of each template, four - it triples the amount, five - it quadruples the amount.</p>
  
  <p><strong>NEWEST EDIT:</strong> So as it turns out, it was the for loop that I was using to try and increment the sequence. I got rid of the loop and hardcoded the sequence to 1. That fixed it.</p>