简体   繁体   中英

Hook into Drupal View after form submit to modify search parameters

Basically I have a view that filters results of job postings. I have the following fields:

Region, Job Field, and Position

What I want to do is hook into the functionality where the user submits the form so that I can do the following:

a ) If the user chooses a position, I don't want to include the Job Field in the search (basically change this to 'all')

b) If the user doesn't specify a position, it will use the Job Field in the search parameters.

I'm not sure which View hook to use and how to manipulate the form data, can anyone help?

If it is useful, I am not using Ajax.

You want to add your own custom submit function using hook_form_alter , this article contains a basic example and should provide a starting point.

The submit handler (second one in the article above) is where you'll want to work your magic, you should easily be able to check the value of your position variable and set the other form elements appropriately. I would suggest using Devel as it provides functions such as dpm() which will pretty-print large arrays such as $form and $form_state to assist you in locating the values you want to check and modify.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM