File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,35 @@ public function showForm(array $options): void {
5858 ]);
5959 }
6060
61+ public function getRenderedHtml ($ domain , $ canEdit = true ): string {
62+ if (!$ canEdit ) {
63+ return $ this ->value . PHP_EOL ;
64+ }
65+
66+ $ html = '' ;
67+ $ id = $ this ->question ->getID ();
68+ $ rand = mt_rand ();
69+ $ fieldName = 'formcreator_field_ ' . $ id ;
70+ $ values = $ this ->getAvailableValues ();
71+
72+ if (!empty ($ this ->question ->fields ['values ' ])) {
73+ $ html .= Dropdown::showFromArray ($ fieldName , $ values , [
74+ 'display_emptychoice ' => $ this ->question ->fields ['show_empty ' ] == 1 ,
75+ 'value ' => $ this ->value ,
76+ 'values ' => [],
77+ 'rand ' => $ rand ,
78+ 'multiple ' => false ,
79+ 'display ' => false ,
80+ ]);
81+ }
82+ $ html .= PHP_EOL ;
83+ $ html .= Html::scriptBlock ("$(function() {
84+ pluginFormcreatorInitializeSelect(' $ fieldName', ' $ rand');
85+ }); " );
86+
87+ return $ html ;
88+ }
89+
6190 public function getAvailableValues () {
6291 if (empty ($ this ->question ->fields ['values ' ])) {
6392 return [];
You can’t perform that action at this time.
0 commit comments