DirectorObjectForm: add getSentOrObjectValue helper

This commit is contained in:
Thomas Gelf 2015-12-03 00:38:59 +01:00
parent 3fade17bf4
commit 5144b8bfed
1 changed files with 22 additions and 0 deletions

View File

@ -692,6 +692,28 @@ abstract class DirectorObjectForm extends QuickForm
return $this->getSentValue($name) === $this->getElement($name)->getLabel(); return $this->getSentValue($name) === $this->getElement($name)->getLabel();
} }
public function getSentOrObjectValue($name, $default = null)
{
if ($this->hasObject()) {
$value = $this->getSentValue($name);
if ($value === null) {
$object = $this->getObject();
if ($object->hasProperty($name)) {
return $object->$name;
}
return $default;
} else {
return $value;
}
} else {
return $this->getSentValue($name, $default);
}
}
public function loadObject($id) public function loadObject($id)
{ {
$class = $this->getObjectClassname(); $class = $this->getObjectClassname();