mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
DirectorObjectForm: allow for string imports...
...and deal with empty choices
This commit is contained in:
parent
fa286d1fcb
commit
6a60b3942c
@ -169,10 +169,10 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||||||
if (! is_array($imports)) {
|
if (! is_array($imports)) {
|
||||||
$imports = array($imports);
|
$imports = array($imports);
|
||||||
}
|
}
|
||||||
$imports = array_values(array_merge(
|
$imports = array_filter(array_values(array_merge(
|
||||||
$imports,
|
$imports,
|
||||||
$this->extractChoicesFromPost($post)
|
$this->extractChoicesFromPost($post)
|
||||||
));
|
)), 'strlen');
|
||||||
|
|
||||||
/** @var ZfElement $el */
|
/** @var ZfElement $el */
|
||||||
$this->populate([$key => $imports]);
|
$this->populate([$key => $imports]);
|
||||||
@ -354,6 +354,9 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||||||
foreach ($values as $key => $value) {
|
foreach ($values as $key => $value) {
|
||||||
try {
|
try {
|
||||||
if ($key === 'imports' && ! empty($this->choiceElements)) {
|
if ($key === 'imports' && ! empty($this->choiceElements)) {
|
||||||
|
if (! is_array($value)) {
|
||||||
|
$value = [$value];
|
||||||
|
}
|
||||||
foreach ($this->choiceElements as $element) {
|
foreach ($this->choiceElements as $element) {
|
||||||
$chosen = $element->getValue();
|
$chosen = $element->getValue();
|
||||||
if (is_string($chosen)) {
|
if (is_string($chosen)) {
|
||||||
@ -482,9 +485,9 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||||||
protected function groupMainProperties()
|
protected function groupMainProperties()
|
||||||
{
|
{
|
||||||
$elements = array(
|
$elements = array(
|
||||||
|
'imports',
|
||||||
'object_type',
|
'object_type',
|
||||||
'object_name',
|
'object_name',
|
||||||
'imports',
|
|
||||||
'display_name',
|
'display_name',
|
||||||
'host_id',
|
'host_id',
|
||||||
'address',
|
'address',
|
||||||
@ -1372,7 +1375,7 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||||||
$object = $this->object();
|
$object = $this->object();
|
||||||
$tpl = $this->db->enumIcingaTemplates($object->getShortTableName());
|
$tpl = $this->db->enumIcingaTemplates($object->getShortTableName());
|
||||||
if (empty($tpl)) {
|
if (empty($tpl)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $object->get('id');
|
$id = $object->get('id');
|
||||||
@ -1381,12 +1384,7 @@ abstract class DirectorObjectForm extends DirectorForm
|
|||||||
unset($tpl[$id]);
|
unset($tpl[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($tpl)) {
|
return array_combine($tpl, $tpl);
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$tpl = array_combine($tpl, $tpl);
|
|
||||||
return $tpl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addExtraInfoElements()
|
protected function addExtraInfoElements()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user