';
-}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 0525ad6f3c8..693cf235cf3 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -3893,7 +3893,7 @@ class Form
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Return list of payment modes.
+ * print list of payment modes.
* Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
* See instead to force the default value by the caller.
*
@@ -3908,8 +3908,28 @@ class Form
public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '')
{
// phpcs:enable
- global $langs, $user, $conf;
+ print $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss);
+ }
+
+ /**
+ * Return list of payment modes.
+ * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want.
+ * See instead to force the default value by the caller.
+ *
+ * @param int $selected Id of payment term to preselect by default
+ * @param string $htmlname Nom de la zone select
+ * @param int $filtertype Not used
+ * @param int $addempty Add an empty entry
+ * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info
+ * @param string $morecss Add more CSS on select tag
+ * @return void
+ */
+ public function getSelectConditionsPaiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '')
+ {
+
+ global $langs, $user, $conf;
+ $out = '';
dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
$this->load_cache_conditions_paiements();
@@ -3919,24 +3939,25 @@ class Form
$selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
}
- print '';
if ($user->admin && empty($noinfoadmin)) {
- print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
+ $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
- print ajax_combobox($htmlname);
+ $out.= ajax_combobox($htmlname);
+ return $out;
}
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 25ab99bfe01..722d7a8f247 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -215,7 +215,7 @@ class FormSetup
$out = '
';
$out .= '';
$out .= '
';
- $out .= '
' . $this->langs->trans("Parameter") . '
';
+ $out .= '
' . $this->langs->trans("Parameter") . '
';
$out .= '
' . $this->langs->trans("Value") . '
';
$out .= '
';
$out .= '';
@@ -560,13 +560,16 @@ class FormSetupItem
/** @var string $helpText */
public $helpText = '';
- /** @var string $value */
+ /** @var string $fieldValue */
public $fieldValue;
+ /** @var array $fieldAttr fields attribute only for compatible fields like input text */
+ public $fieldAttr;
+
/** @var bool|string set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too */
public $fieldOverride = false;
- /** @var bool|string set this var to override field output */
+ /** @var bool|string set this var to override field input */
public $fieldInputOverride = false;
/** @var bool|string set this var to override field output */
@@ -583,6 +586,7 @@ class FormSetupItem
/**
* TODO each type must have setAs{type} method to help configuration
* And set var as protected when its done configuration must be done by method
+ * this is important for retrocompatibility of futures versions
* @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type'
*/
protected $type = 'string';
@@ -598,9 +602,15 @@ class FormSetupItem
*/
public function __construct($confKey)
{
- global $langs, $db, $conf;
+ global $langs, $db, $conf, $form;
$this->db = $db;
- $this->form = new Form($this->db);
+
+ if (!empty($form) && is_object($form) && get_class($form) == 'Form') { // form class have cache inside so I use it for optimise
+ $this->form = $form;
+ } else {
+ $this->form = new Form($this->db);
+ }
+
$this->langs = $langs;
$this->entity = $conf->entity;
@@ -700,6 +710,10 @@ class FormSetupItem
return $this->fieldInputOverride;
}
+ $this->fieldAttr['name'] = $this->confKey;
+ $this->fieldAttr['id'] = 'setup-'.$this->confKey;
+ $this->fieldAttr['value'] = $this->fieldValue;
+
$out = '';
if ($this->type == 'title') {
@@ -726,7 +740,9 @@ class FormSetupItem
$out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1);
}
} else {
- $out.= '';
+ if (empty($this->fieldAttr)) { $this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass); }
+
+ $out.= 'fieldAttr).' />';
}
return $out;