Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.