You are here

function chosen_element_apply_property_recursive in Chosen 7.2

Same name and namespace in other branches
  1. 8.2 chosen.module \chosen_element_apply_property_recursive()
  2. 3.0.x chosen.module \chosen_element_apply_property_recursive()

Recurse through an element to apply the chosen property to any select fields.

1 call to chosen_element_apply_property_recursive()
chosen_pre_render_date_combo in ./chosen.module
Render API callback: Apply Chosen to a date_combo element.

File

./chosen.module, line 280
General functions and hook implementations.

Code

function chosen_element_apply_property_recursive(array &$element, $chosen_value = NULL) {
  if (!isset($chosen_value)) {
    if (isset($element['#chosen'])) {
      $chosen_value = $element['#chosen'];
    }
    else {
      return;
    }
  }
  if (isset($element['#type']) && $element['#type'] == 'select') {
    $element['#chosen'] = $chosen_value;
  }
  foreach (element_children($element) as $key) {
    chosen_element_apply_property_recursive($element[$key], $chosen_value);
  }
}