add setAsSelectUser

This commit is contained in:
Eric Seigne 2023-03-14 15:04:15 +01:00
parent eccb61e95d
commit fba22c8883

View File

@ -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;
}
}