I have created a rather complicated form to be submitted to search/location
. There are two ways to do this, grab the search location form and alter it or if you need to do lots of fancy AJAX stuff which require a vastly different form structure, just recreate it and the lie to Drupal about which form it is -- in other words, steal the identity of search_form
. You only need two lines of code in a form_alter
(you can't do this in form generation as form_id
gets overwritten unconditionally).
$form['form_id']['#value'] = 'search_form';
$form['form_token']['#default_value'] = drupal_get_token('search_form');