Skip to content

Commit

Permalink
fix(form): validators must show when more than 2 available
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Apr 30, 2020
1 parent d125c7c commit fb37c46
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<h2>' . __('Validation', 'formcreator') . '</h2>';
echo '<div class="form-group required liste" id="form-validator">';
echo '<label>' . __('Choose a validator', 'formcreator') . ' <span class="red">*</span></label>';
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 '<h2>' . __('Validation', 'formcreator') . '</h2>';
echo '<div class="form-group required liste" id="form-validator">';
echo '<label>' . __('Choose a validator', 'formcreator') . ' <span class="red">*</span></label>';
Dropdown::showFromArray('formcreator_validator', $validators);
}
}

Expand Down

0 comments on commit fb37c46

Please sign in to comment.