When are '$form_state['values'] copied to '$form' on rebuild? as far as I understand it whenever you submit and rebuild a form (e.g. 'Add another item' on fields with infinite cardinality) something like this happens:


User submits a form with filled values
User input is copied to $form_state
Element validation happens
Form validation happens
drupal_get_form is called (form is being rebuild)
??? old user input from $form_state is copied to every $element[#value]
Individual elements of the form are created in $element[#process] callbacks
Rebuild form is shown to a user


My question is, when and how is user input from the old form transferred into the new one? 

From what I've been able to understand by reading the documentation it must happen somewhere in drupal_build_form before the element #process callback is called. But when exactly that I haven't been able to find.

//I know about this FAPI flowchart if anyone could point me in the right direction on it I'd appreciate it.
Nothing like "??? old user input from $form_state is copied to every $element[#value]" happens. Simply $form_state['input'] is kept so that when the form is built the values are filled in based on that.