IcingaObjectFieldLoader: allow to combine objects

This commit is contained in:
Thomas Gelf 2016-10-20 04:27:43 +00:00
parent f87e80989d
commit c41009992e
1 changed files with 24 additions and 1 deletions

View File

@ -25,13 +25,36 @@ class IcingaObjectFieldLoader
public function addFieldsToForm(QuickForm $form)
{
if ($this->object->supportsFields()) {
if ($this->fields || $this->object->supportsFields()) {
$this->attachFieldsToForm($form);
}
return $this;
}
public function loadFieldsForMultipleObjects($objects)
{
$fields = array();
foreach ($objects as $object) {
foreach ($this->prepareObjectFields($object) as $varname => $field) {
$varname = $field->varname;
if (array_key_exists($varname, $fields)) {
if ($field->datatype !== $fields[$varname]->datatype) {
unset($fields[$varname]);
}
continue;
}
$fields[$field->varname] = $field;
}
}
$this->fields = $fields;
return $this;
}
/**
* Set a list of values
*