Skip to content

Commit 411b998

Browse files
committed
fix(condition): fix show hide issues
1 parent fb2c711 commit 411b998

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

inc/field.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function prepareQuestionInputForTarget($input) {
8181
public function show($canEdit = true) {
8282
$required = ($canEdit && $this->fields['required']) ? ' required' : '';
8383

84-
echo '<div class="form-group ' . $required . '" id="form-group-field' . $this->fields['id'] . '">';
84+
echo '<div class="form-group ' . $required . '" id="form-group-formcreator_field_' . $this->fields['id'] . '">';
8585
echo '<label for="formcreator_field_' . $this->fields['id'] . '">';
8686
echo $this->getLabel();
8787
if ($canEdit && $this->fields['required']) {

inc/fields.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public static function isVisible($id, $values) {
291291

292292
// If the field is hidden by default, show it if condition is true
293293
if ($question->fields['show_rule'] == 'hidden') {
294-
return $return;
294+
return ($return == true);
295295

296296
// else show it if condition is false
297297
} else {

inc/form.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ class='formcreator_form form_horizontal'>";
991991
echo '</div>';
992992

993993
echo '<input type="hidden" name="formcreator_form" value="' . $item->getID() . '">';
994-
echo '<input type="hidden" name="_glpi_csrf_token" value="' . Session::getNewCSRFToken() . '">';
994+
echo Html::hidden('_glpi_csrf_token', ['value' => Session::getNewCSRFToken()]);
995995
echo '<input type="hidden" name="uuid" value="' .$item->fields['uuid'] . '">';
996996
echo '</form>';
997997
}

js/scripts.js.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ function formcreatorChangeValueOf(field_id, value) {
535535
formcreatorShowFields();
536536
}
537537
function formcreatorAddValueOf(field_id, value) {
538-
formcreatorQuestions[field_id] = value;
538+
formcreatorQuestions['formcreator_field_' + field_id] = value;
539539
}
540540

541541
function formcreatorShowFields() {
@@ -550,14 +550,14 @@ function formcreatorShowFields() {
550550
var i = 0;
551551
for (question in formcreatorQuestions) {
552552
if (questionToShow[question]) {
553-
$('#form-group-field' + question).show();
553+
$('#form-group-' + question).show();
554554
i++;
555-
$('#form-group-field' + question).removeClass('line' + (i+1) % 2);
556-
$('#form-group-field' + question).addClass('line' + i%2);
555+
$('#form-group-' + question).removeClass('line' + (i+1) % 2);
556+
$('#form-group-' + question).addClass('line' + i%2);
557557
} else {
558-
$('#form-group-field' + question).hide();
559-
$('#form-group-field' + question).removeClass('line0');
560-
$('#form-group-field' + question).removeClass('line1');
558+
$('#form-group-' + question).hide();
559+
$('#form-group-' + question).removeClass('line0');
560+
$('#form-group-' + question).removeClass('line1');
561561
}
562562
}
563563
});

0 commit comments

Comments
 (0)