Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.167 diff -u -p -r1.167 form.inc --- includes/form.inc 21 Dec 2006 16:16:44 -0000 1.167 +++ includes/form.inc 28 Dec 2006 22:42:46 -0000 @@ -942,6 +942,27 @@ function form_select_options($element, $ } /** + * Traverses a select element #option seeking for the object that holds the + * given key. Returns FALSE if not found. As usual with functions that can + * return 0 or FALSE do not forget to use === and !== if needed. + * + * @param $element + * The select element + * @param $key + * The key to look for + * @return + * The index of the object that helds the $key with some value. + */ +function form_get_option_key($element, $key) { + foreach ($element['#options'] as $index => $object) { + if (isset($object->option[$key])) { + return $index; + } + } + return FALSE; +} + +/** * Format a group of form items. * * @param $element