Merge branch 'bugfix/endpoint-remove-import-12920'

fixes #12920
This commit is contained in:
Markus Frosch 2016-10-13 16:53:59 +02:00
commit f527e31b14
2 changed files with 11 additions and 4 deletions

View File

@ -47,8 +47,14 @@ class IcingaEndpointForm extends DirectorObjectForm
'multiOptions' => $this->optionalEnum($this->db->enumApiUsers())
));
$this->addZoneElement()
->addImportsElement();
$this->addZoneElement();
if ($this->object->hasBeenLoadedFromDb()) {
$imports = $this->object->get('imports');
if ($imports !== null && count($imports) > 0) {
$this->addImportsElement(false);
}
}
$this->setButtons();
}

View File

@ -14,6 +14,7 @@ abstract class DirectorObjectForm extends QuickForm
{
protected $db;
/** @var IcingaObject */
protected $object;
protected $objectName;
@ -1151,7 +1152,7 @@ abstract class DirectorObjectForm extends QuickForm
return $this;
}
protected function addImportsElement()
protected function addImportsElement($required = null)
{
$enum = $this->enumAllowedTemplates();
if (empty($enum)) {
@ -1165,7 +1166,7 @@ abstract class DirectorObjectForm extends QuickForm
. ' matters when importing properties from multiple templates: last one'
. ' wins'
),
'required' => !$this->isTemplate(),
'required' => ($required !== null ? $required : !$this->isTemplate()),
'multiOptions' => $this->optionallyAddFromEnum($enum),
'sorted' => true,
'class' => 'autosubmit'