From 7da6f93d7e5d972fc693c6c6431d9aef63f3d45e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Aug 2017 13:23:15 +0200 Subject: [PATCH] FIX select of category FIX pb with extrafield list and key '0' --- htdocs/core/class/commonobject.class.php | 12 +++++ htdocs/core/class/extrafields.class.php | 18 ++++---- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/install/mysql/migration/repair.sql | 3 +- htdocs/langs/en_US/admin.lang | 10 ++--- .../modulebuilder/template/myobject_list.php | 2 +- htdocs/societe/list.php | 45 +++++++++++-------- 8 files changed, 57 insertions(+), 37 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0693b3dd336..50ccf362de6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4352,6 +4352,12 @@ abstract class CommonObject $this->array_options[$key] = null; } break; + /*case 'select': // Not required, we chosed value='0' for undefined values + if ($value=='-1') + { + $this->array_options[$key] = null; + } + break;*/ case 'price': $this->array_options[$key] = price2num($this->array_options[$key]); break; @@ -4485,6 +4491,12 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + /*case 'select': // Not required, we chosed value='0' for undefined values + if ($value=='-1') + { + $this->array_options[$key] = null; + } + break;*/ case 'price': $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]); break; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 3fcb909fc51..a66648df2c2 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -348,7 +348,7 @@ class ExtraFields $sql .= " " . $user->id . ","; $sql .= "'" . $this->db->idate(dol_now()) . "'"; $sql.=')'; - + dol_syslog(get_class($this)."::create_label", LOG_DEBUG); if ($this->db->query($sql)) { @@ -721,8 +721,8 @@ class ExtraFields { $array_name_label[$tab->name]=$tab->label; } - - + + // Old usage $this->attribute_type[$tab->name]=$tab->type; @@ -740,8 +740,8 @@ class ExtraFields $this->attribute_list[$tab->name]=$tab->list; $this->attribute_hidden[$tab->name]=$tab->ishidden; $this->attribute_entityid[$tab->name]=$tab->entity; - - + + // New usage $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; @@ -759,8 +759,8 @@ class ExtraFields $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; - - + + if (!empty($conf->multicompany->enabled)) { $sql_entity_name='SELECT label FROM '.MAIN_DB_PREFIX.'entity WHERE rowid='.$tab->entity; $resql_entity_name=$this->db->query($sql_entity_name); @@ -944,10 +944,10 @@ class ExtraFields $out.=''; foreach ($param['options'] as $key => $val) { - if ($key == '') continue; + if ((string) $key == '') continue; list($val, $parent) = explode('|', $val); $out.='