Fix for Embedding views exposed widgets within a form

  1. function nrembrowser_build_view(&$options) {
  2.  // Do lots of stuff here...
  3.  
  4.     // Display any exposed filters, but only if called for by the view.
  5.     if ($view->exposed_widgets) {
  6. // Attempted to build the form manually, but seems that's the same as ->exposed_widgets...
  7. //      $form_state = array(
  8. //        'view' => $view,
  9. //        'display' => $view->display_handler->display,
  10. //        'method' => 'get',
  11. //        'rerender' => TRUE,
  12. //        'no_redirect' => TRUE,
  13. //      );
  14. //       $options['exposed_filters'] = drupal_build_form('views_exposed_form', $form_state);
  15.       $options['exposed_filters'] = $view->exposed_widgets;
  16.     }
  17.  
  18. // Do more stuff...
  19. }
  20.  
  21. function nrembrowser_add_media_page_form(&$form_state, $field = NULL, $nid = NULL, $options = array()) {
  22.   $form = array();
  23.   // Random form elements go here...
  24.  
  25.   // Note that $options['view'] contains the view object we reference throughout...
  26.  
  27.   // Do some stuff with our view that's building this form...
  28.   nrembrowser_build_view($options);
  29.  
  30.   if ($options['exposed_filters']) {
  31.     $form['exposed_filters'] = array(
  32.       '#type' => 'item',
  33.       '#value' => $options['exposed_filters'],
  34.     );
  35.   }
  36.  
  37.   // more form elements...
  38.   return $form;
  39. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.