Posted By

WimLeers on 09/30/07


Tagged

textmate drupal FAPI


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

WimLeers
basicmagic
vali29
kellyharding


Helper function to find a form element by reference


 / Published in: PHP
 

  1. /**
  2.  * Helper function to find a form element by reference.
  3.  */
  4. function _find_element(&$element, $element_name, &$form_element) {
  5. if (isset($element[$element_name])) {
  6. $form_element = $element[$element_name];
  7. return TRUE;
  8. }
  9. else {
  10. foreach ($element as $key => $value) {
  11. if (is_array($element[$key])) {
  12. $found = _find_element(&$element[$key], $element_name, &$form_element);
  13. if ($found) {
  14. return TRUE;
  15. }
  16. }
  17. }
  18. }
  19. return FALSE;
  20. }

Report this snippet  

You need to login to post a comment.