From 7a036014c63bb7e4e8aff9ef96f3860a1871fb5b Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 11 Jun 2018 12:11:56 +0200 Subject: [PATCH] LSattr_html :: jsonCompositeAttribute : fix check required method --- ...s.LSformElement_jsonCompositeAttribute.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php b/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php index 578cc7fe..62a579f8 100644 --- a/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php +++ b/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php @@ -270,24 +270,26 @@ class LSformElement_jsonCompositeAttribute extends LSformElement { } } - if (!isset($cconf['multiple']) || !$cconf['multiple']) { - if (count($parseValue[$c])>=1) - $parseValue[$c] = $parseValue[$c][0]; - else - $parseValue[$c] = ''; - } - - if ($cconf['required'] && empty($parseValue[$c])) { - $errors[]=getFData(_('Component %{c} must be defined'),__($cconf['label'])); + if (empty($parseValue[$c])) continue; - } - $unemptyComponents[]=$c; + if (!isset($cconf['multiple']) || !$cconf['multiple']) { + $parseValue[$c] = $parseValue[$c][0]; + } + + $unemptyComponents[]=$c; $value[$c]=$parseValue[$c]; } } if (!empty($unemptyComponents)) { + // Check required components + foreach ($this -> components as $c => $cconf) { + if ($cconf['required'] && !isset($value[$c])) { + $errors[]=getFData(_('Component %{c} must be defined'),__($cconf['label'])); + continue; + } + } foreach($errors as $e) { $this -> form -> setElementError($this -> attr_html,$e); }