From 931a93cd7bae092e2752064568cebe407d2bf46e Mon Sep 17 00:00:00 2001 From: Geo Xalkis Date: Tue, 2 May 2023 01:02:48 +0300 Subject: (almost) final structrure of forms --- public/app/controllers/JsonToForm.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'public/app/controllers') diff --git a/public/app/controllers/JsonToForm.php b/public/app/controllers/JsonToForm.php index 5a60891..1b05af7 100644 --- a/public/app/controllers/JsonToForm.php +++ b/public/app/controllers/JsonToForm.php @@ -181,7 +181,9 @@ class JsonToForm - $html = ''; + $html = " +
+ "; foreach ($formJson->form as $key => $field) { @@ -227,13 +229,13 @@ class JsonToForm } else { // select is single; draw select + add empty option $html .=" - "; - // // prepare initialization of select2 (single) - // $initSelectsJS .= " - // var {$name} = $('#{$name}'); - // {$name}.select2({ allowClear: true });"; + // prepare initialization of select2 (single) + $initSelectsJS .= " + var {$name} = $('#{$name}'); + {$name}.select2({ }); + {$name}.val(null).trigger('change')"; // prepare check if empty field $checkFilledJS .= " @@ -338,7 +340,7 @@ class JsonToForm } return [ - 'html' => $html, + 'html' => $html .'
', 'init_js' => $initSelectsJS, 'values_js' => $checkFilledJS ]; -- cgit v1.2.3