Merging two forms together in Drupal

Versions used: 

Sometimes in Drupal I want to join together two forms, or in other words, prepend a form to another. For example, let say I have three user forms, all different but all contain the same fields to obtain the user address. One day I want to add an address lookup button in the address part of the form, but I'm forced to do the work on all three forms. What if I could create a separate form for just the address, then merge/add/prepend it to other forms. This way, I just need to change the address form and the changes would be reflected in all three of my forms. Here is an example:

Lets say we have our address form, with basic address fields:

<?php
function basic_address_form($form, &$form_state) {
  include_once
DRUPAL_ROOT . '/includes/iso.inc';
 
$form = array();

 
$form['address_1'] = array(
   
'#title' => t('Address 1'),
   
'#type' => 'textfield',
   
'#required' => TRUE,
  );
 
$form['address_2'] = array(
   
'#title' => t('Address 2'),
   
'#type' => 'textfield',
  );
 
$form['contact']['town'] = array(
   
'#title' => t('Town/City'),
   
'#type' => 'textfield',
     
'#required' => TRUE,
  );
 
$form['postcode'] = array(
   
'#title' => t('Postcode'),
   
'#type' => 'textfield',
   
'#size' => 15,
   
'#required' => TRUE,
  );
 
$form['country'] = array(
   
'#type' => 'select',
   
'#title' => t('Country'),
   
'#options' => _country_get_predefined_list(),
   
'#default_value' => 'GB',
  );
 
$form['submit'] = array(
   
'#type' => 'submit',
   
'#value' => t('Submit'),
  );

  return
$form;
}
?>

The address form will look like this:

[wa_tokens:wa_tokens_basic_address_form]

Now we add a basic form with some other generic user fields:

<?php
function basic_user_details_form($form, &$form_state) {
 
$form = array();

 
$form['first_name'] = array(
   
'#type' => 'textfield',
   
'#title' => t('First Name'),
  );
 
$form['last_name'] = array(
   
'#type' => 'textfield',
   
'#title' => t('Last Name'),
  );
 
$form['company'] = array(
   
'#type' => 'textfield',
   
'#title' => t('Company Name'),
  );
 
$form['submit'] = array(
   
'#type' => 'submit',
   
'#value' => t('Submit'),
  );

  return
$form;
}
?>

which looks like this:

[wa_tokens:wa_tokens_basic_user_details_form]

What we want to do is merge the user details form and user address form together. This is easy, we just need to add two lines in our user detail form, before the submit button, like this:

<?php
// ...
$extra = basic_address_form($form, $form_state);
$form = array_merge_recursive($form, $extra);
// ...
?>

So we end up with a merged form like this:

[wa_tokens:wa_tokens_basic_address_form_add]