Sanitizes the options recursively to support optgroups.
$options: The option array.
$properties: An array containing the properties of the widget.
function _options_prepare_options(&$options, $properties) {
foreach ($options as $value => $label) {
// Recurse for optgroups.
if (is_array($label)) {
_options_prepare_options($options[$value], $properties);
}
else {
if ($properties['strip_tags']) {
$options[$value] = strip_tags($label);
}
if ($properties['filter_xss']) {
$options[$value] = field_filter_xss($label);
}
}
}
}