From 8bce409db0333285920b0dd9618a41956e9811a6 Mon Sep 17 00:00:00 2001 From: simicar29 <53998265+simicar29@users.noreply.github.com> Date: Mon, 10 Feb 2020 13:14:42 +0100 Subject: [PATCH 1/5] Show extrafields only when enabled Show extrafields only in context where they are enabled (especially in edit mode that uses the showOptionals function). --- htdocs/core/class/commonobject.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c7dbab57b31..299fe0c8817 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6624,7 +6624,12 @@ abstract class CommonObject if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue; // @todo Add test also on 'enabled' (different than 'list' that is 'visibility') - //$enabled = 1; + $enabled = 1; + if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) + { + $enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1); + } + if (empty($enabled)) continue; $visibility = 1; if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key])) From 6b6355f373a6da044373bd944a187f8fde569c48 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 11 Feb 2020 09:57:52 +0100 Subject: [PATCH 2/5] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a74872d4a98..1383b6221b9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3498,6 +3498,7 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment methods + * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. * * @param string $selected Id du mode de paiement pre-selectionne * @param string $htmlname Nom de la zone select @@ -3513,7 +3514,7 @@ class Form public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') { // phpcs:enable - global $langs, $user; + global $langs, $user, $conf; dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); @@ -3523,6 +3524,9 @@ class Form elseif ($filtertype != '' && $filtertype != '-1') $filterarray = explode(',', $filtertype); $this->load_cache_types_paiements(); + + // Set default value if not already set by caller + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID; print '