Dynamic Form Field Submit Handler This form creates dynamic fields. I am trying to build a submit handler for each of the dynamic field values.  So for each of the $form['items_fieldset'][$i]['serial'], (amount, and description) I could have many fields.  How would I pass those to my database?

Here's what I have thusfar:

Form excerpt:

$form['#tree'] = TRUE;

$form['items_fieldset'] = array(
'#type' =&gt; 'fieldset',
'#title' =&gt; t('Shippment Inventory Items:'),
'#prefix' =&gt; '&lt;div id="items-fieldset-wrapper"&gt;',
'#suffix' =&gt; '&lt;/div&gt;',
); 

 if (empty($form_state['num_items'])) {
$form_state['num_items'] = 1;
} 


 for ($i = 0; $i &lt; $form_state['num_items']; $i++) {

$form['items_fieldset'][$i] = array(
'#prefix' =&gt; '&lt;div class="two-col"&gt;',
'#suffix' =&gt; '&lt;/div&gt;'
);

$form['items_fieldset'][$i]['amount'] = array(
  '#type' =&gt; 'textfield',
  '#size' =&gt; 30,
  '#title' =&gt; t('Amount:'),
  '#required' =&gt; FALSE,
  '#prefix' =&gt; '&lt;div style="float:left; padding-right: 50px;"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
);

$form['items_fieldset'][$i]['description'] = array(
  '#type' =&gt; 'textfield',
  '#size' =&gt; 50,
  '#title' =&gt; t('Description:'),
  '#required' =&gt; FALSE,
  '#prefix' =&gt; '&lt;div style="float:left; padding-right: 50px;"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;',
); 

$form['items_fieldset'][$i]['serial'] = array(
  '#type' =&gt; 'textfield',
  '#size' =&gt; 30,
  '#title' =&gt; t('Serial Number:'),
  '#required' =&gt; FALSE,
  '#prefix' =&gt; '&lt;div style="float:left;"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;',
);
} 

$form['items_fieldset']['add_items'] = array(
'#type' =&gt; 'submit',
'#value' =&gt; t('Add more'),
'#submit' =&gt; array('_nnreport_shipping_new_add_one'),
'#ajax' =&gt; array(
    'callback' =&gt; '_nnreport_shipping_new_callback',
    'wrapper' =&gt; 'items-fieldset-wrapper',
    ),
); 


Handler to pass to database (not including all the static form values):

 function _nnreport_shipping_new_submit($form, &amp;$form_state) {
    $submission = new stdClass();
    //This doesnt work, but I think it's kinda what I'm after...?? 
     for ($i = 0; $i &lt; $form_state['num_items']; $i++) {
          $submission=&gt;amount.$i = $form_state['values']['$i']['amount'];

          };
          _nnreport_shipping_new_update($submission); }


After that I submit the values of $submission to the database, like this:

function _nnreport_shipping_new_update(&amp;$submission){

     db_insert('nnj_shipment')
        -&gt;fields(array(
            'hotshotId' =&gt; $submission-&gt;carrier,
            'driver' =&gt; $submission-&gt;driver,
            'driverPhone' =&gt; $submission-&gt;driverPhone,
             //lots more of those...
              ))
             -&gt;execute();


I've unsuccessfully tried a few variations to get the dynamic fields into the object...I would be very grateful for someone to point me in the correct direction.
Well after ignoring this problem for a while it was time to find an answer.

The issue was with using $form['#tree'] = TRUE; 
I didn't use the full array references after that...eg:
$form_state[$i]['description'] needed to be
$form_state['values']['items_fieldset'][$i]['description'] = 'foo';
(

After that I just used a foreach to grab my values from the dynamic field values...like:
foreach ($form_state['values']['items_fieldset'] as $v){
$submission->description[] = $v['description'];
}

And last was to dump them into my DB, and life is good.