I’m using answers from Expose a view's filters both in a block, and in the actual view to duplicate an exposed filter as a block and make it appear in another region on every page.
I want to style both form copies a bit differently. When I started to look into the markup, I noticed that I’m getting two forms with identical IDs. Putting aside the styling, that’s not good.
The code I am using is the following.
function MYMODULE_block_view($delta = ''){ $block = array(); switch($delta){ case 'mysearch': $block['subject'] = t('My Search'); $block['content'] = _MYMODULE_get_exposed_filter_form(); break; } return $block; } /** Function to get the Exposed filter form **/ function _MYMODULE_get_exposed_filter_form(){ $view = views_get_view('node_index_view'); $view->set_display('page'); $view->init_handlers(); $exposed_form = $view->display_handler->get_plugin('exposed_form'); return $exposed_form->render_exposed_form(); }
How do I alter the ID of the copied exposed filter block? If I use hook_form_alter()
or hook_form_views_exposed_form_alter()
it’s going to apply the alteration to both instances.