From fba22c8883c4440620c02167c3469772ec606c6f Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Tue, 14 Mar 2023 15:04:15 +0100 Subject: [PATCH] add setAsSelectUser --- htdocs/core/class/html.formsetup.class.php | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 40dec1870a4..26e892c1151 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -833,6 +833,8 @@ class FormSetupItem $out.= $this->generateInputFieldMultiSelect(); } elseif ($this->type == 'select') { $out.= $this->generateInputFieldSelect(); + } elseif ($this->type == 'selectUser') { + $out.= $this->generateInputFieldSelectUser(); } elseif ($this->type == 'textarea') { $out.= $this->generateInputFieldTextarea(); } elseif ($this->type== 'html') { @@ -992,6 +994,14 @@ class FormSetupItem return $this->form->selectarray($this->confKey, $this->fieldOptions, $this->fieldValue); } + /** + * @return string + */ + public function generateInputFieldSelectUser() + { + return $this->form->select_dolusers($this->fieldValue, $this->confKey); + } + /** * get the type : used for old module builder setup conf style conversion and tests * because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist @@ -1066,6 +1076,8 @@ class FormSetupItem $out.= $this->generateOutputFieldMultiSelect(); } elseif ($this->type == 'select') { $out.= $this->generateOutputFieldSelect(); + } elseif ($this->type == 'selectUser') { + $out.= $this->generateOutputFieldSelectUser(); } elseif ($this->type== 'html') { $out.= $this->fieldValue; } elseif ($this->type== 'color') { @@ -1185,6 +1197,17 @@ class FormSetupItem return $outPut; } + /** + * @return string + */ + public function generateOutputFieldSelectUser() + { + $outPut = ''; + $user = new User($this->db); + $user->fetch($this->fieldValue); + $outPut = $user->firstname . " " . $user->lastname; + return $outPut; + } /* * METHODS FOR SETTING DISPLAY TYPE */ @@ -1335,4 +1358,16 @@ class FormSetupItem $this->type = 'select'; return $this; } + + /** + * Set type of input as a simple title + * no data to store + * @param array $fieldOptions A table of field options + * @return self + */ + public function setAsSelectUser() + { + $this->type = 'selectUser'; + return $this; + } }