Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a form and I would like to take the value from it, and use it as input for a page view which is created using exposed filters.
I have created a submit handler for my first form. I then redirect to the page view. The challenge is that I want to include search keys in the redirection. I can't figure out how to get this to work because the characters ? and = are converted.

I have created this function.

function my_module_my_button_submit($form, &$form_state) {
  $url = 'some-path/search?keys=' . check_plain($form_state['values']['input']);
  $form_state['redirect'] = $url;

The URL that is created from this is 'http://site/some-path/search%3Fkeys%3Dtest'; the URL I want is 'http://site/some-path/search?keys=test'.

share|improve this question
up vote 5 down vote accepted

In Drupal 6, instead of setting `$form_state['redirect'] with a string, you set it with an array with tree items.

$form_state['redirect'] = array('some-path/search', 'keys=' . check_plain($form_state['values']['input']), '');

The last item would be a value used as anchor. As in your case you don't need it, pass an empty string.

share|improve this answer
Super! Worked perfectly, thanks! (And it was a D6 question). – chipcleary Apr 18 '11 at 15:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.