Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.7
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Nov 2009 at 21:24 UTC
Updated:
30 Aug 2010 at 05:25 UTC
I need to embed a views exposed filter form in a node create form, and I came across this code for doing it. The problem is, drupal_build_form (which is a views function) returns the rendered HTML, but since I'm in hook_form_alter, I need the data in array from so I can add it to the $form array. Is there another function or method I could call to get the exposed filter form data in array form?
Thanks.
Comments
Comment #1
wonder95 commentedI got the form to display by calling views_exposed_form():
Then, I specified a submit function and added two more textareas to the form:
The next trick is getting the search_results area to be filled with data returned by the view that uses the exposed filters. I'm assuming I'll need to call views_exposed_form_submit() to get the data, and then write it to the textarea. Is that the correct function to call?
Thanks.
Comment #2
dawehnerThere is $view->set_exposed_input($filters); But i'm not sure how $filters looks exact.
I suggest to create another view, and get the $view object and have a look at $view->exposed_input. After this, you can use the function.
Comment #3
merlinofchaos commentedThey will look just like they do from $_GET where the 'key' to the filter is the identifier that is set in the UI. It is pretty easy to construct exposed filter input this way.
Comment #4
wonder95 commentedOK, so that tells me how to get the filter data, and set it. It sounds like I read from $_GET and create $filters, and call $view->set_exposed_input.
How do I go from there? I'm using the multiselect widget to create my target field, so I want to put the results of the view in the left field when I submit the form. Do I specify my own submit function and then call views_exposed_form_submit? How do I get the data returned from the view so I can put it in that field?
Thanks.
Comment #5
wonder95 commentedComment #6
tema commentedSorry, I've make it active again.
@wonder95 Do you embed a view into a node form?
The method of exposed form is GET. How to get it working beside another elements of a node form?
Comment #7
esmerel commentedPlease do not reopen issues like this. if you need help, open a new issue, and reference this one.