0

I is possible to:

  1. Hook on views_pre_view (which is executed before form_alter)
  2. Query view data (execute the view query filtering according to URL parameters) and collect some data
  3. Hook on form_alter
  4. Replace some selects using data collected on item 2?

I'm asking because if I $view->execute() inside views_pre_view (to filter and use view data) it will internally call form_alter and generate the form before I'm able to collect the data to pre-populate my selects. And I'm not sure if it's possible to re-generate a form that was already generated.

I also tried views_pre_execute but this one is always executed after form_alter.

Cheers!

New contributor
Antonio Carlos Ribeiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • Hi, may you be so kind to rephrase your question? I am unsure about which is the final goal of this task. Are you willing to, given a view result, modify a form and insert some data from the view? Are you willing to modify exposed filters? Is something different? I don't fully understand the question. – jbarrio Feb 23 at 10:05
0

The only way I found for now was to, inside views_pre_view, deep clone the $view object using $view = unserialize(serialize($_view)), so when Drupal passes again on form_alter the form would be untouched and I can just recreate some selects.

New contributor
Antonio Carlos Ribeiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Antonio Carlos Ribeiro is a new contributor. Be nice, and check out our Code of Conduct.

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.