How to restore form values from $form_state['values']? I save the $form_sate['values'] in a data base. When my users come back to the form I want to show the values that they put before. Something like:

function my_form($form, &amp;$form_sate) {
  $form_state_saved = get_form_state_values_from_db();

  $form['my_field'] = array(
    ...
    '#default_value' = $form_state_saved['my_field'];
    ...
  );

  return $form;
}


With a textfield seems that works fine, but I have some custom fields. Is there a way to set the default_value from db? Or should I implement the default_value independently for each field?
Use Form default value:

'#default_value' =&gt; variable_get('sitename_textfield', ''),


If you use system_settings_form() you don't need to manually save your variables using a custom form submit function. Note: The variable must have the same name as the form item.

Function details: https://api.drupal.org/api/drupal/modules!system!system.module/function/system_settings_form/7

/**
 * Creates/returns a form to configure the variables.
 *
 * @param array $form
 * @param array $form_state
 * @return array
 */
function sitename_custom_form($form, &amp;$form_state) {
  $form['sitename_textfield'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Custom Textfield'),
    '#default_value' =&gt; variable_get('sitename_textfield', ''),
  );

  // Use system_settings_form() to automate saving configuration variables.
  return system_settings_form($form);
}