protected function AssertContentTrait::getSelectedItem in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/simpletest/src/AssertContentTrait.php \Drupal\simpletest\AssertContentTrait::getSelectedItem()
Get the selected value from a select field.
Parameters
\SimpleXmlElement $element: SimpleXMLElement select element.
Return value
bool The selected value or FALSE.
1 call to AssertContentTrait::getSelectedItem()
- AssertContentTrait::assertFieldsByValue in core/
modules/ simpletest/ src/ AssertContentTrait.php - Asserts that a field exists in the current page with a given Xpath result.
File
- core/
modules/ simpletest/ src/ AssertContentTrait.php, line 992 - Contains \Drupal\simpletest\AssertContentTrait.
Class
- AssertContentTrait
- Provides test methods to assert content.
Namespace
Drupal\simpletestCode
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;
}