Reusing drupal forms in a profile installation?
The problem

A bad implementation of your code is causing the confusion. The input data is not stored in the $form_state variable, but in $form_state['input'] initially.

Once the user submit a form, Drupal will build the form again and process the values. In this step, the system make some checks. You can take a look of functions that have been called.



The function _form_builder_handle_input_element($form_id, &amp;$element, &amp;$form_state) is the one that set the values in $form.

The previous function is called in the middle of form_builder().  At the end of same function, drupal will fill the values in '$form_state' variable .

Why the function is not filling the values?

Because the next code is checking the input form:

// Set a flag if we have a correct form submission. This is always TRUE for
// programmed forms coming from drupal_form_submit(), or if the form_id coming
// from the POST data is set and matches the current form_id.

if ($form_state['programmed'] || (!empty($form_state['input']) &amp;&amp; (isset($form_state['input']['form_id']) &amp;&amp; ($form_state['input']['form_id'] == $form_id)))) {
  $form_state['process_input'] = TRUE;
}
else {
  $form_state['process_input'] = FALSE;
}


The result is FALSE because $form_state['input']['form_id'] != $form_id.

'site_google_analytics_form' != 'googleanalytics_admin_settings_form'


So, the input finally is not processed for security reasons

Solution

Your code should be implemented like this:

/*
* hook_install_tasks(&amp;$install_state)
*/
function hook_install_tasks(&amp;$install_state){

$tasks['site_google_analytics_form'] = array(
        'display' =&gt; TRUE,
        'type' =&gt; 'form',
        'display_name' =&gt; st('Google Analytics Configuration'),
);

return $tasks;


}

/**
* Configure google analytics.  The only required field is the tracking code.
*/
function site_google_analytics_form($form, &amp;$form_state){

    module_load_include('inc', 'googleanalytics', 'googleanalytics.admin');
    return googleanalytics_admin_settings_form($form, $form_state);

}


The run_task() call itself the drupal_get_form(), so it was no necessary call yourself in your code.