@@ -537,7 +537,18 @@ public function showForm($ID, $options = []) {
537537 $ questions = $ DB ->request ($ request );
538538 $ last_section = '' ;
539539 $ questionsCount = $ questions ->count ();
540+ $ fields = [];
540541 while ($ question_line = $ questions ->next ()) {
542+ $ question = new PluginFormcreatorQuestion ();
543+ $ question ->getFromDB ($ question_line ['id ' ]);
544+ $ fields [$ question_line ['id ' ]] = PluginFormcreatorFields::getFieldInstance (
545+ $ question_line ['fieldtype ' ],
546+ $ question
547+ );
548+ $ fields [$ question_line ['id ' ]]->deserializeValue ($ question_line ['answer ' ]);
549+ }
550+ $ questions ->rewind ();
551+ while ($ question_line = $ questions ->current ()) {
541552 // Get and display current section if needed
542553 if ($ last_section != $ question_line ['section_name ' ]) {
543554 echo '<h2> ' .$ question_line ['section_name ' ].'</h2> ' ;
@@ -548,19 +559,14 @@ public function showForm($ID, $options = []) {
548559 || ($ question_line ['fieldtype ' ] != "description "
549560 && $ question_line ['fieldtype ' ] != "hidden " )
550561 ) {
551- $ question = new PluginFormcreatorQuestion ();
552- $ question ->getFromDB ($ question_line ['id ' ]);
553- $ field = PluginFormcreatorFields::getFieldInstance (
554- $ question_line ['fieldtype ' ],
555- $ question
556- );
557- $ field ->deserializeValue ($ question_line ['answer ' ]);
558- $ field ->show ($ canEdit );
562+ // if (PluginFormcreatorFields::isVisible($question_line['id'], $fields)) {
563+ // }
564+ $ fields [$ question_line ['id ' ]]->show ($ canEdit );
559565 }
566+ $ questions ->next ();
560567 }
561- $ formName = 'formcreator_form ' . $ formId ;
562568 echo Html::scriptBlock ('$(function() {
563- formcreatorShowFields($("form[name= \'' . $ formName . ' \']"));
569+ formcreatorShowFields($("form[name= \'form \']"));
564570 }) ' );
565571
566572 //add requester info
@@ -599,6 +605,8 @@ public function showForm($ID, $options = []) {
599605 echo '<input type="submit" name="accept_formanswer" class="submit_button" value=" ' . __ ('Accept ' , 'formcreator ' ) . '" /> ' ;
600606 echo '</div> ' ;
601607 echo '</div> ' ;
608+ $ options ['canedit ' ] = true ;
609+ $ options ['candel ' ] = false ;
602610 }
603611 }
604612
0 commit comments