support value= attribute for model optiondata, for https://github.com/opnsense/core/issues/1832

This commit is contained in:
Ad Schellevis 2017-09-19 16:35:20 +02:00
parent 93c40a5e93
commit c7c1c55c8e

View File

@ -96,7 +96,13 @@ abstract class BaseModel
} else {
$result = array();
foreach ($xmlNode->children() as $childNode) {
$result[$childNode->getName()] = $this->parseOptionData($childNode);
// item keys can be overwritten using value attributes
if (empty($childNode->attributes()['value'])) {
$itemKey = (string)$childNode->getName();
} else {
$itemKey = (string)$childNode->attributes()['value'];
}
$result[$itemKey] = $this->parseOptionData($childNode);
}
}
return $result;