From fb37c460cc08e1bd75b5a69daa6aa252b86266bc Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Tue, 28 Apr 2020 11:35:55 +0200 Subject: [PATCH] fix(form): validators must show when more than 2 available Signed-off-by: Thierry Bugier --- inc/form.class.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/inc/form.class.php b/inc/form.class.php index 78790a1ac..758c9bea9 100644 --- a/inc/form.class.php +++ b/inc/form.class.php @@ -1248,19 +1248,17 @@ class='formcreator_form form_horizontal'>"; break; } - switch (count($result)) { - case 1: - reset($validators); - $validatorId = key($validators); - echo Html::hidden('formcreator_validator', ['value' => $validatorId]); - break; - case 2: - $validators = [0 => Dropdown::EMPTY_VALUE] + $validators; - echo '

' . __('Validation', 'formcreator') . '

'; - echo '
'; - echo ''; - Dropdown::showFromArray('formcreator_validator', $validators); - break; + $resultCount = count($result); + if ($resultCount == 1) { + reset($validators); + $validatorId = key($validators); + echo Html::hidden('formcreator_validator', ['value' => $validatorId]); + } else if ($resultCount > 1) { + $validators = [0 => Dropdown::EMPTY_VALUE] + $validators; + echo '

' . __('Validation', 'formcreator') . '

'; + echo '
'; + echo ''; + Dropdown::showFromArray('formcreator_validator', $validators); } }