Ajax ignoring my default_value I have a drupal form that contains a select box. Next to the select box is a link that pops a ctools modal up with an inner form that adds a value to the database table that drives the original select box. When someone clicks submit on the modal form, I would like to rebuild the select box on the original form and set the new value to the default. I've had success with adding the new elements to the select box by doing some ajax in the form_submit hook for the modal form, but it seems like Drupal ignores the value in #default_value in my render array. I have the following in my form_submit hook after the database update and after getting the render array from another function:

if(isset($id)) {
   $newdata['data_source']['#default_value'] = $id;
}
$commands = array();
$commands[] = ctools_modal_command_dismiss();
$commands[] = ajax_command_html('#measure-data-source', drupal_render($newdata));
print ajax_render($commands);
exit();


Again, the select box is getting the new value, and my render array seems fine. I just can't get it to select the new value by default.
Alright, so this is slightly hackey, but I got this to work. I totally gave up on trying to set a default value in the render array, and instead did the drupal_render and set it to a variable. I then modified the html directly in the variable. The code I originally posted now looks like this:

if(isset($id) &amp;&amp; is_numeric($id)) {
  $newrender = drupal_render($newdata);
  $newrender = str_replace('value="'.$id.'"', 'value="'.$id.'"  selected="selected"', $newrender);
}

$commands = array();
$commands[] = ctools_modal_command_dismiss();
$commands[] = ajax_command_html('#measure-data-source', $newrender);
print ajax_render($commands);
exit();


If anyone on here has a more elegant solution, I'd be happy to know the "correct way" of doing this, but this produces the desired result.