@@ -525,15 +525,25 @@ public function showForm($ID, $options = []) {
525525
526526 echo '<ol> ' ;
527527 $ 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+
528536 $ sections = (new PluginFormcreatorSection )->getSectionsFromForm ($ form ->getID ());
529537 foreach ($ sections as $ section ) {
530538 $ sectionId = $ section ->getID ();
531539
532540 // Section header
541+ $ hiddenAttribute = $ visibility [$ section ->getType ()][$ sectionId ] ? '' : 'hidden="" ' ;
533542 echo '<li '
534543 . ' class="plugin_formcreator_section" '
535544 . ' data-itemtype=" ' . PluginFormcreatorSection::class . '" '
536545 . ' data-id=" ' . $ sectionId . '" '
546+ . " $ hiddenAttribute "
537547 . '"> ' ;
538548
539549 // section name
@@ -544,14 +554,6 @@ public function showForm($ID, $options = []) {
544554 // Section content
545555 echo '<div> ' ;
546556
547- // Get fields populated with answers
548- $ answers = $ this ->getAnswers (
549- $ this ->getID (),
550- [
551- PluginFormcreatorSection::getForeignKeyField () => $ section ->getID (),
552- ]
553- );
554-
555557 // Display all fields of the section
556558 $ lastQuestion = null ;
557559 $ questions = (new PluginFormcreatorQuestion )->getQuestionsFromSection ($ sectionId );
@@ -569,7 +571,7 @@ public function showForm($ID, $options = []) {
569571 }
570572 }
571573 }
572- echo $ question ->getRenderedHtml ($ domain , $ canEdit , $ answers );
574+ echo $ question ->getRenderedHtml ($ domain , $ canEdit , $ answers, $ visibility [ $ question -> getType ()][ $ question -> getID ()] );
573575 $ lastQuestion = $ question ;
574576 }
575577 echo '</div> ' ;
0 commit comments