[icinga-checkins] icinga.org: icingaweb2-module-director/master: DirectorObjectForm: normalize command field values...

git at icinga.org git at icinga.org
Fri Aug 26 15:52:18 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 77c915c8971597f688d2aa14a21511c9dd0081c2
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=77c915c8971597f688d2aa14a21511c9dd0081c2

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri Aug 26 13:48:44 2016 +0000

DirectorObjectForm: normalize command field values...

...with special data types even when filled at services level

fixes #12400
fixes #11692
fixes #11477

---

 library/Director/Web/Form/DirectorObjectForm.php |   26 ++++++++++++----------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php
index 2b0043c..cd42b46 100644
--- a/library/Director/Web/Form/DirectorObjectForm.php
+++ b/library/Director/Web/Form/DirectorObjectForm.php
@@ -300,19 +300,21 @@ abstract class DirectorObjectForm extends QuickForm
 
                     // Get value through form element.
                     // TODO: reorder the related code. Create elements once
-                    if (property_exists($fields, $mykey)) {
-                        $field = $fields->$mykey;
-                        $datafield = DirectorDatafield::load($field->datafield_id, $this->getDb());
-                        $name = 'var_' . $datafield->varname;
-                        $className = $datafield->datatype;
-
-                        if (class_exists($className)) {
-                            $datatype = new $className;
-                            $datatype->setSettings($datafield->getSettings());
-                            $el = $datatype->getFormElement($name, $this);
+                    foreach (array($fields, $checkFields) as $fieldSet) {
+                        if (property_exists($fieldSet, $mykey)) {
+                            $field = $fieldSet->$mykey;
+                            $datafield = DirectorDatafield::load($field->datafield_id, $this->getDb());
+                            $name = 'var_' . $datafield->varname;
+                            $className = $datafield->datatype;
+
+                            if (class_exists($className)) {
+                                $datatype = new $className;
+                                $datatype->setSettings($datafield->getSettings());
+                                $el = $datatype->getFormElement($name, $this);
+                            }
+
+                            $value = $el->setValue($value)->getValue();
                         }
-
-                        $value = $el->setValue($value)->getValue();
                     }
 
                     if (property_exists($fields, $mykey) && $fields->$mykey->format === 'json') {



More information about the icinga-checkins mailing list