1.20.x backdrop_web_test_case.php | protected BackdropWebTestCase::getSelectedItem(SimpleXMLElement $element) |
Get the selected value from a select field.
Parameters
$element: SimpleXMLElement select element.
Return value
The selected value or FALSE.:
File
- modules/
simpletest/ backdrop_web_test_case.php, line 3560
Class
- BackdropWebTestCase
- Test case for typical Backdrop tests.
Code
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;
}