From 440ed897ffa30eadb601872ed8fa7b120cb658d2 Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 7 Jul 2022 11:32:42 +0200 Subject: [PATCH 1/2] ADD multiselect support in Form::formconfirm() Use 'multiselect' type to add a multi select field in form confirm questions. --- htdocs/core/class/html.form.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9568ec25828..b969d664ca3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4911,7 +4911,7 @@ class Form * @param string $question Question * @param string $action Action * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>)) - * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', 'other' or 'onecolumn'... + * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'select', 'multiselect', 'morecss', 'other' or 'onecolumn'... * @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0' * @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx * @param int|string $height Force height of box (0 = auto) @@ -4982,7 +4982,7 @@ class Form $moreonecolumn .= $input['value']; $moreonecolumn .= ''; $moreonecolumn .= ''; - } elseif ($input['type'] == 'select') { + } elseif (in_array($input['type'],['select', 'multiselect'])) { if (empty($morecss)) { $morecss = 'minwidth100'; } @@ -4999,7 +4999,11 @@ class Form if (!empty($input['label'])) { $more .= $input['label'].'
'; } - $more .= $this->selectarray($input['name'], $input['values'], isset($input['default'])?$input['default']:'', $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss); + if ($input['type'] == 'select') { + $more .= $this->selectarray($input['name'], $input['values'], $input['default'], $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss); + } else { + $more .= $this->multiselectarray($input['name'], $input['values'], is_array($input['default']) ? $input['default'] : [$input['default']], $key_in_label, $value_as_key, $morecss, $translate, $maxlen, $moreattr); + } $more .= '
'."\n"; } elseif ($input['type'] == 'checkbox') { $more .= '
'; From fc6eb42ae7fd5e4d6825c8d866e7a8da84d03efd Mon Sep 17 00:00:00 2001 From: jyhere Date: Thu, 7 Jul 2022 11:52:44 +0200 Subject: [PATCH 2/2] Missing space --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b969d664ca3..aeaa02035bd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4982,7 +4982,7 @@ class Form $moreonecolumn .= $input['value']; $moreonecolumn .= ''; $moreonecolumn .= '
'; - } elseif (in_array($input['type'],['select', 'multiselect'])) { + } elseif (in_array($input['type'], ['select', 'multiselect'])) { if (empty($morecss)) { $morecss = 'minwidth100'; }