Adding form elements via ajax; input not stored in $form_state['values'] I am trying to add a date, start time, end time to a form - the user can add as many 'rows' as necessary.  The form fields are being added to the form correctly, and the $form_state['input'] is showing the correct values that were input on the form. However, the $form_state['values'] is only showing the last one, e.g. if I add three (bringing the total to 4) it only includes the last value.

Relevant code in the form builder:

$num_dates = !isset($form_state['num_dates']) ? 1 : $form_state['num_dates'];
$form_state['num_dates'] = $num_dates;
$form['date']['#prefix'] = '&lt;div id="form-date-wrapper"&gt;';
$form['date']['#suffix'] = '&lt;/div&gt;&lt;!-- /#form-date-wrapper --&gt;';
for ($i = 1; $i &lt;= $num_dates; $i ++)
{
  $form['date']['calendar_date' . $num_dates] = array(
    '#title' =&gt; 'Date',
      '#type' =&gt; 'textfield',
      '#maxlength' =&gt; 15,
      '#attributes' =&gt; array('class' =&gt; array('calendar-date')),
      '#prefix' =&gt; '&lt;div class="form-date-entry-wrapper form-row form-row-single-item"&gt;',
  );
  $form['date']['event_start_time' . $num_dates] = array(
  '#title' =&gt; 'Start Time',
      '#type' =&gt; 'select',
      '#options' =&gt; drupal_map_assoc(array(t('9:00 AM'), t('9:15 AM'))),
      '#attributes' =&gt; array('class' =&gt; array('calendar-date-times')),
  );
  $form['date']['event_end_time' . $num_dates] = array(
  '#title' =&gt; 'End Time',
      '#type' =&gt; 'select',
      '#options' =&gt; drupal_map_assoc(array(t('9:00 AM'), t('9:15 AM'))),
      '#suffix' =&gt; '&lt;/div&gt; &lt;!-- /form-date-entry-wrapper --&gt;',
      '#attributes' =&gt; array('class' =&gt; array('calendar-date-times')),
  );
}
$form['add_another_date_time'] = array(
  '#type' =&gt; 'submit',
    '#title' =&gt; 'Add Another Date/Time',
    '#value' =&gt; 'Add Another Date/Time',
    '#limit_validation_errors' =&gt; array(),
    '#attributes' =&gt; array('class' =&gt; array('look-like-text-button')),
    '#submit' =&gt; array('exhibitorevents_form_add_date_time_submit'),
    '#ajax' =&gt; array(
      'callback' =&gt; 'exhibitorevents_form_add_date_time',
        'wrapper' =&gt; 'form-date-wrapper',
        'method' =&gt; 'append',
        'effect' =&gt; 'fade',
    ),
);
    $form['submit'] = array(
  '#title' =&gt; 'Submit',
  '#type' =&gt; 'submit',
  '#value' =&gt; 'submit',
  '#weight' =&gt; 100,
);


And the callback functions:

/**
 * Ajax callback for add more dates/times
 */
function exhibitorevents_form_add_date_time($form, $form_state) {
  return $form['date'];
}
/**
 * Submit handler for add more dates/times button
 * 
 * Increments num_dates +1
 */
 function exhibitorevents_form_add_date_time_submit($form, &amp;$form_state) {
   $form_state['num_dates']++;  
   $form_state['rebuild'] = TRUE;
 }


I have added the $form_state['input'] &amp; $form_state['values'] array here: http://pastebin.com/nL3DWHm8 for reference.  This particular example, I added one date 'row', making 2 total.
You should add the $form['#tree'] so that all the values are passed.