diff --git a/application/forms/IcingaServiceForm.php b/application/forms/IcingaServiceForm.php index 5fe5f45e..8de92307 100644 --- a/application/forms/IcingaServiceForm.php +++ b/application/forms/IcingaServiceForm.php @@ -497,13 +497,7 @@ class IcingaServiceForm extends DirectorObjectForm ->addExtraInfoElements() ->setButtons(); - if ($this->hasBeenSent()) { - $name = $this->getSentOrObjectValue('object_name'); - if (!strlen($name)) { - $this->setElementValue('object_name', end($imports)); - $this->object->object_name = end($imports); - } - } + $this->setDefaultNameFromTemplate($imports); } /** @@ -547,13 +541,7 @@ class IcingaServiceForm extends DirectorObjectForm ->addExtraInfoElements(); } - if ($this->hasBeenSent()) { - $name = $this->getSentOrObjectValue('object_name'); - if (!strlen($name)) { - $this->setElementValue('object_name', end($imports)); - $this->object->object_name = end($imports); - } - } + $this->setDefaultNameFromTemplate($imports); } public function setServiceSet(IcingaServiceSet $set) @@ -759,4 +747,18 @@ class IcingaServiceForm extends DirectorObjectForm return parent::onSuccess(); } + + /** + * @param array $imports + */ + protected function setDefaultNameFromTemplate($imports) + { + if ($this->hasBeenSent()) { + $name = $this->getSentOrObjectValue('object_name'); + if (!strlen($name)) { + $this->setElementValue('object_name', end($imports)); + $this->object->set('object_name', end($imports)); + } + } + } }