Forms: centralize groups property loading

This commit is contained in:
Thomas Gelf 2015-06-17 11:11:25 +02:00
parent a25bb80004
commit b15e814151
4 changed files with 15 additions and 7 deletions

View File

@ -97,11 +97,4 @@ class IcingaHostForm extends DirectorObjectForm
$this->addElement('submit', $this->translate('Store'));
}
public function loadObject($id)
{
parent::loadObject($id);
$this->getElement('groups')->setValue(implode(', ', $this->object->groups()->listGroupNames()));
return $this;
}
}

View File

@ -80,6 +80,11 @@ class IcingaServiceForm extends DirectorObjectForm
'description' => $this->translate('Check this host in this specific Icinga cluster zone')
));
$this->addElement('text', 'groups', array(
'label' => $this->translate('Servicegroups'),
'description' => $this->translate('One or more comma separated servicegroup names')
));
$this->addElement('submit', $this->translate('Store'));
}
}

View File

@ -55,6 +55,11 @@ class IcingaUserForm extends DirectorObjectForm
'description' => $this->translate('Check this user in this specific Icinga cluster zone')
));
$this->addElement('text', 'groups', array(
'label' => $this->translate('Usergroups'),
'description' => $this->translate('One or more comma separated usergroup names')
));
$this->addElement('submit', $this->translate('Store'));
}
}

View File

@ -116,6 +116,11 @@ abstract class DirectorObjectForm extends QuickForm
$this->addHidden('id');
}
$this->setDefaults($this->object->getProperties());
if ($this->object->supportsGroups()) {
$this->getElement('groups')->setValue(
implode(', ', $this->object->groups()->listGroupNames())
);
]
if ($this->object->supportsCustomVars()) {
foreach ($this->object->vars() as $key => $value) {