OOPS!
Yes, as I said, the aforementioned code is not really tested at all, and I discovered soon after posting there was an error. The _isInOptGroup function from the above code should be replaced with this:
function _isInOptGroup($v, $opts) {
$isInOptGroup = false;
foreach ($opts as $opt) {
if (isset($opt['options'])) {
$isInOptGroup = $this->_isInOptGroup($v, $opt['options']);
} else {
if ($v == $opt['attr']['value']) {
$isInOptGroup = true;
}
}
if ($isInOptGroup) break;
}
return $isInOptGroup;
}
The break; clause is the bit that changed.
Sorry. Use at your own risk.

How about a patch for Quickform 1 for those of us who can't upgrade to Quickform2 yet. It looks like it is possible by using one of or a combination of the hacks above, but I'm unclear on which bit of which hack to take. Perhaps Chris Yates or Tom Walter can throw together a patch and post it up here?