1

If I have a form that posts data to a view page, how do I go about setting the contextual filter in my view?

Here is sample code I tried running but it's not working:

$data = 'name=value&name1=value1';

$options = array(
            'method' => 'POST',
            'data' => $data,
            'timeout' => 15,
            'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
    );

 drupal_http_request('http://www.mysite.com/companylist', $options)
  • Please provides some more background about what you're trying to do. This is very minimal explanation. – beth Sep 12 '13 at 18:24
  • I thought I was clear sorry. I want to grab the posted data and use them in my where clause (contextual filter). – Brian Sep 12 '13 at 18:31
  • Does the form submission page redirect to the view? Or is it submitting with AHAH on the same page? How is the view related to the form? – beth Sep 12 '13 at 19:11
  • I have an regular HTML form that is a post to a view page. I can get it to work with the GET method because the contextual filters grabs the data right from the URL. I'm just not sure how to grab the data if it is a POST. Thanks for your help. – Brian Sep 12 '13 at 19:16
  • You mean you're not using the form API? Why are you using a regular HTML form in Drupal? – beth Sep 12 '13 at 19:58
1

Your POST might be accessible at contextual filters -> Provide default argument -> PHP code -> $_POST.

| improve this answer | |
  • I tried this originally and it didn't work. Then I saw your post and figured I would try it again and it worked. I must have been cached. – Brian Sep 16 '13 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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