lib/api

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Wed May 8 18:05:09 CEST 2013


 lib/api/kolab_api_service_form_value.php |   16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 06b41dffda81a3687f2c00b6cd49f75c6d7ebc8d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Wed May 8 18:03:58 2013 +0200

    Correct the use of "optional" and "validate" for "form_fields"

diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 33f57c4..2767dc1 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -223,9 +223,21 @@ class kolab_api_service_form_value extends kolab_api_service
                 }
             }
 
-            if (array_key_exists($attr_name, $attribs['form_fields']) && empty($attribs['form_fields'][$attr_name]['optional'])) {
+            if (array_key_exists($attr_name, $attribs['form_fields'])) {
+                if (empty($attribs['form_fields'][$attr_name]['optional'])) {
+                    $attribs['form_fields'][$attr_name]['optional'] = false;
+                }
+            }
+
+            if (array_key_exists($attr_name, $attribs['form_fields'])) {
+                if (empty($attribs['form_fields'][$attr_name]['validate'])) {
+                    $attribs['form_fields'][$attr_name]['validate'] = true;
+                }
+            }
+
+            if ($attribs['form_fields'][$attr_name]['optional'] && !($attribs['form_fields'][$attr_name]['validate'])) {
                 $result[$attr_name] = $this->{$method_name}($attr_value, $postdata);
-            } else if (array_key_exists($attr_name, $attribs['form_fields']) && empty($attribs['form_fields'][$attr_name]['validate'])) {
+            } else if (!($attribs['form_fields'][$attr_name]['validate'])) {
                 $result[$attr_name] = $attr_value;
             } else {
                 try {





More information about the commits mailing list