function mefibs_set_form_id_recursive in MEFIBS - More exposed forms in blocks 7
Same name and namespace in other branches
- 8 mefibs.module \mefibs_set_form_id_recursive()
Recursivly prefix the #id attribute of all elements in a form.
Parameters
array $form: Form API array.
string $prefix: The string to use as a prefix.
1 call to mefibs_set_form_id_recursive()
- mefibs_exposed_block_form in ./
mefibs.module - Form builder for the additional exposed form.
File
- ./
mefibs.module, line 784 - Primarily Drupal hooks and global API functions to manipulate views and to provide an additional block with an exposed filter form.
Code
function mefibs_set_form_id_recursive(&$form, $prefix) {
foreach (element_children($form) as $element) {
if ($element == 'mefibs_form') {
continue;
}
if (isset($form[$element]['#id'])) {
if (strpos($form[$element]['#id'], 'edit-') === 0) {
$form[$element]['#id'] = drupal_html_id('edit-' . $prefix . '-' . substr($form[$element]['#id'], 5));
}
else {
$form[$element]['#id'] = drupal_html_id($prefix . '-' . $form[$element]['#id']);
}
}
if (count(element_children($form[$element]))) {
mefibs_set_form_id_recursive($form[$element], $prefix);
}
}
}