3

I have a view content page. I want to filters its content on the base of a custom form data. So how we can pass or filter a view content using custom form data there?

View is built on node. In this particular node we have a field type select list. The same select list we have created in our form. Now what ever option is selected in form, we want to use it's value in view. We also do not have idea how to use its value.

8
  • for Drupal 8???
    – No Sssweat
    May 6, 2016 at 9:32
  • No,In drupal 7. May 6, 2016 at 9:36
  • 1
    Expand the question with details like: What is the entity that the view is built on e.g. Node or Node revision or Taxonomy or Custom entity etc? What filter do you want to apply to your view? Is it node id filter? title filter? search? Currently there's really no way to answer your question in a meaningful way. All I can say is (in the current question format): Google it.
    – Beebee
    May 6, 2016 at 9:44
  • 1
    does the form redirect to view after submit May 6, 2016 at 10:25
  • 2
    @ArunaSingh it'd be great if you can answer your own question with a code sample of how you achieved it and accept it as the answer, this way others who run into same issue know what to do! (and the question will no longer appear on teh unanswered list) May 9, 2016 at 13:47

1 Answer 1

1

Assuming the custom form sits in its own page. You can rewrite the output of the field, using replacement patterns, in the view to pass the required information as part of the url.

Then using hook_menu, define parameters to pass to the form

function hello_world_menu() {
  $items=array();
  $items['hello_world/%/%'] = array (
    'title' => 'My Custom Form',
    'page callback' => 'hello_world_form_function',
    'page arguments' => array(1,2),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
);
return $items;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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