From 319f14f94b888bcdcdb54a64e1926b47e5df75be Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 3 Jul 2017 15:24:22 +0200 Subject: [PATCH] IcingaTemplateChoiceServiceForm: add missing form --- .../forms/IcingaTemplateChoiceServiceForm.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 application/forms/IcingaTemplateChoiceServiceForm.php diff --git a/application/forms/IcingaTemplateChoiceServiceForm.php b/application/forms/IcingaTemplateChoiceServiceForm.php new file mode 100644 index 00000000..3a89a617 --- /dev/null +++ b/application/forms/IcingaTemplateChoiceServiceForm.php @@ -0,0 +1,59 @@ +object(); + + $this->addElement('text', 'object_name', array( + 'label' => $this->translate('Choice name'), + 'required' => true, + 'description' => $this->translate( + 'This will be shown as a label for the given choice' + ) + )); + + $this->addElement('textarea', 'description', array( + 'label' => $this->translate('Description'), + 'rows' => 4, + 'description' => $this->translate( + 'A detailled description explaining what this choice is all about' + ) + )); + + $this->addElement('extensibleSet', 'members', array( + 'label' => $this->translate('Available choices'), + 'required' => true, + 'ignore' => true, + 'description' => $this->translate( + 'Your users will be allowed to choose among those templates' + ), + 'value' => $object->getChoices(), + 'multiOptions' => $this->fetchUnboundTemplates() + )); + + $this->setButtons(); + } + + protected function fetchUnboundTemplates() + { + $db = $this->getDb()->getDbAdapter(); + $query = $db->select()->from( + ['o' => 'icinga_service'], + [ + 'k' => 'o.object_name', + 'v' => 'o.object_name', + ] + )->where("o.object_type = 'template'"); + + return $db->fetchPairs($query); + } +}