diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index a788964c..b75310c9 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -711,6 +711,35 @@ abstract class DirectorObjectForm extends QuickForm list($set[$key + 1], $set[$key]) = array($set[$key], $set[$key + 1]); } + protected function beforeSetup() + { + if (!$this->hasBeenSent()) { + return; + } + + $post = $values = $this->getRequest()->getPost(); + + foreach ($post as $key => $value) { + + if (preg_match('/^(.+?)_(\d+)__(MOVE_DOWN|MOVE_UP|REMOVE)$/', $key, $m)) { + $values[$m[1]] = array_filter($values[$m[1]], 'strlen'); + switch ($m[3]) { + case 'MOVE_UP': + $this->moveUpInSet($values[$m[1]], $m[2]); + break; + case 'MOVE_DOWN': + $this->moveDownInSet($values[$m[1]], $m[2]); + break; + case 'REMOVE': + $this->removeFromSet($values[$m[1]], $m[2]); + break; + } + + $this->getRequest()->setPost($m[1], $values[$m[1]]); + } + } + } + protected function onRequest() { $values = array(); @@ -729,26 +758,6 @@ abstract class DirectorObjectForm extends QuickForm $values[$key] = $value; } } - - foreach ($post as $key => $value) { - - if (preg_match('/^(.+?)_(\d+)__(MOVE_DOWN|MOVE_UP|REMOVE)$/', $key, $m)) { - $values[$m[1]] = array_filter($values[$m[1]], 'strlen'); - switch ($m[3]) { - case 'MOVE_UP': - $this->moveUpInSet($values[$m[1]], $m[2]); - break; - case 'MOVE_DOWN': - $this->moveDownInSet($values[$m[1]], $m[2]); - break; - case 'REMOVE': - $this->removeFromSet($values[$m[1]], $m[2]); - break; - } - - $this->getRequest()->setPost($m[1], $values[$m[1]]); - } - } } if ($object instanceof IcingaObject) { $this->handleProperties($object, $values);