This is for Drupal 7.
I am trying to modify an exposed filter's id in views. Basically we've noticed a use-case with multiple simple hierarchical selects on a given page, in separate exposed filter forms will conflict because they're using the same id attribute in the HTML.
The solution we've come up to to solve this is to append a short hash to the end of this id, making it unique across the page.
The problem is that I'm having trouble figuring out exactly where to do this, and the views objects' immense size doesn't help me in tracking down exactly where I have to make this change.
I'm trying things like this (this is in hook_views_pre_view):
$view->display['DISPLAY_NAME']->handler->options['filters']['field_FIELD_NAME_HASH-HERE'] = $view->display['DISPLAY_NAME']->handler->options['filters']['FIELD_NAME'];
$view->display['DISPLAY_NAME']->handler->options['filters']['field_FIELD_NAME_HASH-HERE']['expose']['identifier'] = 'field_FIELD_NAME_HASH-HERE';
$view->display['DISPLAY_NAME']->handler->options['filters']['field_FIELD_NAME']['expose']['operator_id'] = 'field_FIELD_NAME_HASH-HERE_op';
However this only seems to throw an error.
So how do I change the id on a given exposed filter for a view/display?
EDIT - this is the markup I am trying to affect:
<div class="form-item form-type-select form-item-field-FIELD_NAME shs-wrapper-processed">
<select class="element-invisible shs-enabled form-select shs-processed" id="edit-field-FIELD_NAME" name="field_FIELD_NAME" style="display: none;"><option value="All" selected="selected"><option></option></select>
<select id="edit-field-FIELD_NAME-select-1" class="shs-select form-select shs-select-level-1 chosen-disable" style="display: inline-block;"><option></option></select></div>
Everywhere that has FIELD_NAME either has the default field name, or if I change it in Views, the changed identifier, however I can't seem to change any of these names programmatically - even with the answer below, which is what I really need to do.
How do I affect this markup?
Here is my current hook_preprocess_views_exposed_form:
if($vars['form']['#id'] == 'views-exposed-form-reference-views-block-1') {
$number = <NUMBERHERE>;
$vars['form']['#info']['filter-field_FIELD_NAME']['value'] = 'field_FIELD_NAME_' . $number;
$vars['form']['field_FIELD_NAME_' . $number] = $vars['form']['field_FIELD_NAME'];
$vars['form']['field_FIELD_NAME_' . $number]['#id'] = 'edit-FIELD-NAME-' . $number;
$vars['form']['field_FIELD_NAME_' . $number]['#parents'] = array('field_FIELD_NAME_' . $number);
$vars['form']['field_FIELD_NAME_' . $number]['#array_parents'] = array('field_FIELD_NAME_' . $number);
$vars['form']['field_FIELD_NAME_' . $number]['#name'] = 'field_FIELD_NAME_' . $number;
$vars['widgets']['filter-field_FIELD_NAME']->id = 'edit_field_FIELD-NAME-' . $number;
unset($vars['form']['field_FIELD_NAME']);
}