@@ -525,15 +525,25 @@ public function showForm($ID, $options = []) {
525
525
526
526
echo '<ol> ' ;
527
527
$ domain = PluginFormcreatorForm::getTranslationDomain ($ _SESSION ['glpilanguage ' ], $ form ->getID ());
528
+
529
+ // Get fields populated with answers
530
+ $ answers = $ this ->getAnswers (
531
+ $ this ->getID ()
532
+ );
533
+ $ answers ['plugin_formcreator_forms_id ' ] = $ form ->getID ();
534
+ $ visibility = PluginFormcreatorFields::updateVisibility ($ answers );
535
+
528
536
$ sections = (new PluginFormcreatorSection )->getSectionsFromForm ($ form ->getID ());
529
537
foreach ($ sections as $ section ) {
530
538
$ sectionId = $ section ->getID ();
531
539
532
540
// Section header
541
+ $ hiddenAttribute = $ visibility [$ section ->getType ()][$ sectionId ] ? '' : 'hidden="" ' ;
533
542
echo '<li '
534
543
. ' class="plugin_formcreator_section" '
535
544
. ' data-itemtype=" ' . PluginFormcreatorSection::class . '" '
536
545
. ' data-id=" ' . $ sectionId . '" '
546
+ . " $ hiddenAttribute "
537
547
. '"> ' ;
538
548
539
549
// section name
@@ -544,14 +554,6 @@ public function showForm($ID, $options = []) {
544
554
// Section content
545
555
echo '<div> ' ;
546
556
547
- // Get fields populated with answers
548
- $ answers = $ this ->getAnswers (
549
- $ this ->getID (),
550
- [
551
- PluginFormcreatorSection::getForeignKeyField () => $ section ->getID (),
552
- ]
553
- );
554
-
555
557
// Display all fields of the section
556
558
$ lastQuestion = null ;
557
559
$ questions = (new PluginFormcreatorQuestion )->getQuestionsFromSection ($ sectionId );
@@ -569,7 +571,7 @@ public function showForm($ID, $options = []) {
569
571
}
570
572
}
571
573
}
572
- echo $ question ->getRenderedHtml ($ domain , $ canEdit , $ answers );
574
+ echo $ question ->getRenderedHtml ($ domain , $ canEdit , $ answers, $ visibility [ $ question -> getType ()][ $ question -> getID ()] );
573
575
$ lastQuestion = $ question ;
574
576
}
575
577
echo '</div> ' ;
0 commit comments