Is there a way to pass a form #value to the form #action in Drupal 7 form API? In the example below I want to take elements from the form and include them as part of the URL that I am submitting the form (using #action) so the submitted URL would look like http://example.com/name_storage/John/Lewis/123412341234. 

    &lt;?php


function my_module_menu() {
  $items[‘testform’] = array(
    'title' =&gt; 'First Last Name',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('my_module_form'),
    'access callback' =&gt; TRUE,
    );
  return $items;
}

function my_module_form($form,&amp;$form_submit) {
  $form[‘first_name’] = array(
    '#title' =&gt; t(The first name of the person),
    '#type' =&gt; 'textfield',
    '#required' =&gt; TRUE,
  );
  $form[‘last_name’] = array(
    '#title' =&gt; t('The first name of the person'),
    '#type' =&gt; 'textfield',
    '#required' =&gt; TRUE,
  );
  $form['passcode'] = array(
    '#title' =&gt; t('Passcode for this domain.'),
    '#type' =&gt; 'textfield',
    '#value' =&gt; '123412341234',
    '#required' =&gt; TRUE,
  );
  $form['submit'] = array(
    '#value' =&gt; ‘Submit,
    '#type' =&gt; 'submit',
    );
  $form['#action'] = url('http://example.com/name_storage/' . $form['first_name']['#value'] . '/'. $form['first_name']['#value'] . '/' . $form['passcode']['#value']);
  return $form;
}
?&gt;
In FAPI, #action changes the form's action parameter, which, you should not override if you want to make Drupal handle the submission. 

In your case, you need to define a custom submit handler and redirect the user in that function. You could do something similar by changing the form's method to GET, but it is not possible to define a complex path like the one you want. 

Remove this line:

$form['#action'] = url('http://example.com/name_storage/' . $form['first_name']['#value'] . '/'. $form['first_name']['#value'] . '/' . $form['passcode']['#value']);


Then, add a new submit handler like this:

function my_module_form_submit($form,&amp;$form_state) {
  $values = $form_state['values']['first_name'] . '/'. $form_state['values']['last_name'] . '/' . $form_state['values']['passcode'];
  $form_state['redirect'] = 'name_storage/' . $values;
}


To set the redirect parameter to an external URL, you can do this:

$values = 'http://example.com/name_storage/';
$values .= $form_state['values']['first_name'] . '/'. $form_state['values']['last_name'] . '/' . $form_state['values']['passcode'];
$form_state['redirect'] = array(
  $values,
  array(
    'external' =&gt; TRUE,
  ),
);