Form fields getting cleared off of user inputs after validation errors This question is almost exactly my problem, but I'm not making the mistake made by that poster. As in, I'm not using #value to populate my fields, but the proper #default-value.

I'm working with ubercart, and the form I made is part of a checkout pane. Unfortunately, I have had to use drupal_get_form() within the main uc-cart-checkout-form as the value of a checkout pane. Otherwise, I cannot provide independent submit buttons or clump them together properly.

The problem is that after validation, the form fields are getting cleared out. Only the default values are being reset. I have tried writing a validation handler (even if actually the validation is taking place in a custom validation function that I'm calling from the hook_form_alter() of uc_cart_checkout_form)

Is doing this manually with SESSIONS the only way out? By calling a drupal_get_form inside a drupal_get_form, am I confusing FAPI irrevocably?
I reckon using the ternary conditional operator to check if there is anything in $form_state['values'] would get there, i.e. something like:

$default_value = 'Test Default Value';

$form['test'] = array(
  '#type' =&gt; 'textfield',
  '#default_value' =&gt; !empty($form_state['values']['test'])?$form_state['values']['test']:$default_value,
);