Form element #default_value and AJAX I can't get a form to display a (default?) value after an AJAX call. I am using the following code:

function foo_form ($form, &amp;$form_state, $foo) {

  $form['#prefix'] = '&lt;div id="foo-form-wrapper"&gt;';
  $form['#suffix'] = '&lt;/div&gt;';

  $form['copy'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Copy foo'),
    '#limit_validation_errors' =&gt; array(),
    // #submit is required to use #limit_validation_errors
    '#submit' =&gt; array('foo_form_submit'),
    '#ajax' =&gt; array(
      'wrapper' =&gt; 'foo-form-wrapper',
      'callback' =&gt; 'foo_form_callback',
    ),
  );

  $form['description'] = array(
    '#type' =&gt; 'textarea',
    '#title' =&gt; t('Short description'),
    '#required' =&gt; TRUE,
    '#maxlength' =&gt; 255,
    '#default_value' =&gt; $foo-&gt;description,
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Save'),
  );

  return $form;
}

function foo_form_callback($form, $form_state) {
  return $form;
}

function foo_form_submit ($form, &amp;$form_state) {
  if (!isset($form_state['triggering_element']['#ajax'])) {
    $foo = (object)$form_state['values'];

    entity_get_controller('foo')-&gt;save($foo);

    $form_state['redirect'] = 'admin/foo';
    return;
  } else {
    form_set_value($form['description'], 'description text', $form_state);
    $form_state['rebuild'] = true;
  }
}


As I understand it, the form should automatically try to display the value if it is set in $form_state. When the callback is executed and the form is built, $form_state['values']['description'] is the value set in foo_form_submit. However, nothing is being displayed.
I know this is late, but for people like me who are still experiencing similar problems with ajax and forms in Drupal, here's how I fixed this.
In your ajax callback function, instead of returning just the render array, you need to call the form_builder() function and return its result.
Eg., my code goes like this:

function inventory_purchase_item_add_ajax(&amp;$form, &amp;$form_state) {
    //...

    unset($form_state['input']['line']);
    unset($form_state['values']['line']);

    //Update the form's lines array
    $lines = update_inventory_purchase_form_lines($form_state['node']-&gt;line, $purchase_item_count);
    $form['vtab1']['purchase']['items_wrapper']['line'] = $lines;
    return form_builder($form['#id'], $lines, $form_state);
}