IcingaHostForm: no groups element with no groups
This commit is contained in:
parent
7ef09b99dc
commit
c8a95f1de6
|
@ -25,19 +25,7 @@ class IcingaHostForm extends DirectorObjectForm
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->addElement('extensibleSet', 'groups', array(
|
$this->addGroupsElement();
|
||||||
'label' => $this->translate('Groups'),
|
|
||||||
'multiOptions' => $this->optionallyAddFromEnum($this->enumHostgroups()),
|
|
||||||
'positional' => false,
|
|
||||||
'description' => $this->translate(
|
|
||||||
'Hostgroups that should be directly assigned to this node. Hostgroups can be useful'
|
|
||||||
. ' for various reasons. You might assign service checks based on assigned hostgroup.'
|
|
||||||
. ' They are also often used as an instrument to enforce restricted views in Icinga Web 2.'
|
|
||||||
. ' Hostgroups can be directly assigned to single hosts or to host templates. You might'
|
|
||||||
. ' also want to consider assigning hostgroups using apply rules'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
$this->addImportsElement();
|
$this->addImportsElement();
|
||||||
|
|
||||||
$this->addElement('text', 'display_name', array(
|
$this->addElement('text', 'display_name', array(
|
||||||
|
@ -134,6 +122,29 @@ class IcingaHostForm extends DirectorObjectForm
|
||||||
$this->setButtons();
|
$this->setButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function addGroupsElement()
|
||||||
|
{
|
||||||
|
$groups = $this->enumHostgroups();
|
||||||
|
if (empty($groups)) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addElement('extensibleSet', 'groups', array(
|
||||||
|
'label' => $this->translate('Groups'),
|
||||||
|
'multiOptions' => $this->optionallyAddFromEnum($groups),
|
||||||
|
'positional' => false,
|
||||||
|
'description' => $this->translate(
|
||||||
|
'Hostgroups that should be directly assigned to this node. Hostgroups can be useful'
|
||||||
|
. ' for various reasons. You might assign service checks based on assigned hostgroup.'
|
||||||
|
. ' They are also often used as an instrument to enforce restricted views in Icinga Web 2.'
|
||||||
|
. ' Hostgroups can be directly assigned to single hosts or to host templates. You might'
|
||||||
|
. ' also want to consider assigning hostgroups using apply rules'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function enumHostgroups()
|
protected function enumHostgroups()
|
||||||
{
|
{
|
||||||
$db = $this->db->getDbAdapter();
|
$db = $this->db->getDbAdapter();
|
||||||
|
|
Loading…
Reference in New Issue