From 2bab21c2d8d99cffb58368f8b364deb9bb6bd996 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 2 Aug 2015 15:18:55 +0200 Subject: [PATCH] DirectorObjectForm: prefill object with defaults --- library/Director/Web/Form/DirectorObjectForm.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index ebd0caaf..8445895f 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -23,6 +23,11 @@ abstract class DirectorObjectForm extends QuickForm if ($this->object === null) { $class = $this->getObjectClassname(); $this->object = $class::create($values, $this->db); + foreach ($this->getValues() as $key => $value) { + if ($this->object->hasProperty($key)) { + $this->object->$key = $value; + } + } } else { if (! $this->object->hasConnection()) { $this->object->setConnection($this->db);