DirectorObjectForm: improve getSentOrObjectValue()

This commit is contained in:
Thomas Gelf 2016-02-04 16:51:53 +01:00
parent e56424a20d
commit 7a6bae9430

View File

@ -708,15 +708,23 @@ abstract class DirectorObjectForm extends QuickForm
public function getSentOrObjectValue($name, $default = null)
{
// TODO: check whether getSentValue is still needed since element->getValue
// is in place (currently for form element default values only)
if ($this->hasObject()) {
$value = $this->getSentValue($name);
if ($value === null) {
$object = $this->getObject();
if ($object->hasProperty($name)) {
if ($object->hasProperty($name) && $object->$name !== null) {
return $object->$name;
}
if (null !== ($val = $this->getElement('object_type')->getValue())) {
return $val;
}
return $default;
} else {
@ -724,7 +732,15 @@ abstract class DirectorObjectForm extends QuickForm
}
} else {
return $this->getSentValue($name, $default);
if (null !== ($val = $this->getSentValue($name))) {
return $val;
}
if (null !== ($val = $this->getElement('object_type')->getValue())) {
return $val;
}
return $default;
}
}