You are here

function mefibs_set_form_property_recursive in MEFIBS - More exposed forms in blocks 7

Same name and namespace in other branches
  1. 8 mefibs.module \mefibs_set_form_property_recursive()

Recursivly assign a value to a form property and all its children.

Parameters

array $form: Form API array.

string $property: The name of the property, that is the array key without the leading #.

mixed $value: The new value for the property.

array $exclude: Array with the name of form form children that should not be affected.

1 call to mefibs_set_form_property_recursive()
mefibs_hide_exposed_form_items in ./mefibs.module
Hide form elements that should not show up for the given block id.

File

./mefibs.module, line 764
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_property_recursive(&$form, $property, $value, $exclude = array()) {
  foreach (element_children($form) as $element) {
    if (count($exclude) && in_array($element, $exclude)) {
      continue;
    }
    $form[$element]['#' . $property] = $value;
    if (count(element_children($form[$element]))) {
      mefibs_set_form_property_recursive($form[$element], $property, $value, $exclude);
    }
  }
}