By hubris on
I have a form where the user types in a taxonomy term (which is autocompleted). When the user submits the form, I want the taxonomy term appended to the url.
How do I write the code so that the taxonomy term that is entered is included in the redirect url?
function find_a_lawyer() {
$form['taxonomy']['tags'][$vocabulary->vid] = array(
'#type' => 'textfield',
'#default_value' => $typed_string,
'#size' => 30,
'#maxlength' => 100,
'#autocomplete_path' => 'taxonomy/autocomplete/5'. $vocabulary->vid,
'#required' => $vocabulary->required,
'#title' => $vocabulary->name,
'#description' => t('Enter the State or Province where you would like to find a representative").')
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
$form['#redirect'] = array('node/FindLawyer/'.$arg);
$output = drupal_get_form('find_a_lawyer', $form);
return $output;
Comments
submit function?
Where's your submit function? How is $vocabulary->vid getting in there? Are you doing this for several vocabs? Try something like this:
---
Work: BioRAFT
Still not there... but I found something that works
Hi Pwolanin,
I had tried many variations on the code... the one I pasted (without the submit) was just the latest desperate variation...
I tried your code, but it wasn't working..
$arg = $form_values[$vocabulary->vid];still returns nothing...The Forms Quickstart guide says that that array tree element is the name/key that the value will be under... but neither your code or mine was ...properly... accessing the value under the correct key.
So I tried something a little off the wall:
... I explicitly named that form element as just 'tags'. And in the submit routine I assigned $arg1 to that key/value...
and it worked.... I'm still not sure why the tutorial (http://drupal.org/node/42552 ) on using autocomplete had the last tree element as [$vocabulary->vid] , or what that actually resolves to.. I tried printing all POST and GET variables on submit, and it wasn't showing anything.
Thank though. Problem solved...
-Chris