diff --git a/application/forms/IcingaCommandArgumentForm.php b/application/forms/IcingaCommandArgumentForm.php index 62b7534e..f7b0503b 100644 --- a/application/forms/IcingaCommandArgumentForm.php +++ b/application/forms/IcingaCommandArgumentForm.php @@ -116,7 +116,7 @@ class IcingaCommandArgumentForm extends DirectorObjectForm $this->translate('The argument %s has successfully been stored'), $object->argument_name ); - $object->store($this->db); + $cmd->store($this->db); } else { $this->setHttpResponseCode(304); $msg = $this->translate('No action taken, object has not been modified'); diff --git a/library/Director/Objects/IcingaArguments.php b/library/Director/Objects/IcingaArguments.php index 3743d0f7..8f15800e 100644 --- a/library/Director/Objects/IcingaArguments.php +++ b/library/Director/Objects/IcingaArguments.php @@ -82,9 +82,16 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer public function set($key, $value) { - $argument = IcingaCommandArgument::create( - $this->mungeCommandArgument($key, $value) - )->set('command_id', $this->object->id); + if ($value instanceof IcingaCommandArgument) { + $argument = $value; + } else { + $argument = IcingaCommandArgument::create( + $this->mungeCommandArgument($key, $value) + ); + } + + $argument->set('command_id', $this->object->id); + $key = $argument->argument_name; if (array_key_exists($key, $this->arguments)) { $this->arguments[$key]->replaceWith($argument);