Get the selected value from a select field.
$element: SimpleXMLElement select element.
The selected value or FALSE.
protected function getSelectedItem(SimpleXMLElement $element) {
foreach ($element
->children() as $item) {
if (isset($item['selected'])) {
return $item['value'];
}
elseif ($item
->getName() == 'optgroup') {
if ($value = $this
->getSelectedItem($item)) {
return $value;
}
}
}
return FALSE;
}