rectorObjectForm: catch errors when setting props

This commit is contained in:
Thomas Gelf 2016-03-05 15:58:24 +01:00
parent d990abf0df
commit f073b4d6a9
1 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Form; namespace Icinga\Module\Director\Web\Form;
use Exception;
use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Objects\DirectorDatafield; use Icinga\Module\Director\Objects\DirectorDatafield;
use Zend_Form_Element_Select as Zf_Select; use Zend_Form_Element_Select as Zf_Select;
@ -187,7 +188,13 @@ abstract class DirectorObjectForm extends QuickForm
protected function handleProperties($object, & $values) protected function handleProperties($object, & $values)
{ {
if ($this->hasBeenSent()) { if ($this->hasBeenSent()) {
$object->setProperties($values); foreach ($values as $key => $value) {
try {
$object->set($key, $value);
} catch (Exception $e) {
$this->getElement($key)->addError($e->getMessage());
}
}
} }
$props = $object->getProperties(); $props = $object->getProperties();