diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d312cd98a16..dcef22e2cbd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6968,6 +6968,13 @@ abstract class CommonObject $attributeUnique = $extrafields->attributes[$this->table_element]['unique'][$attributeKey]; $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey]; $attributeEmptyOnClone = $extrafields->attributes[$this->table_element]['emptyonclone'][$attributeKey]; + /* + $attributeEnabled = $extrafields->attributes[$this->table_element]['enabled'][$attributeKey]; + $enabled = 0; + if (!empty($extrafields->attributes[$this->table_element]['enabled'][$key])) { + $enabled = (int) dol_eval((string) $extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); + } + */ // If we clone, we have to clean unique extrafields to prevent duplicates. // If we clone, we have to clean extrafields having "empty on clone" option on. @@ -6985,7 +6992,7 @@ abstract class CommonObject } // Similar code than into insertExtraFields - if ($attributeRequired) { + if ($attributeRequired) { // If attribute is "Mandatory", then it is also in database as "Not null", so we must check even if attribute is not 'enabled'. $v = $this->array_options[$key]; if (ExtraFields::isEmptyValue($v, $attributeType)) { $langs->load("errors"); @@ -7441,15 +7448,16 @@ abstract class CommonObject $value = $this->array_options["options_".$key]; $attributeKey = $key; - $attributeType = $extrafields->attributes[$this->table_element]['type'][$key]; - $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$key]; - $attributeParam = $extrafields->attributes[$this->table_element]['param'][$key]; - $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key]; + $attributeType = $extrafields->attributes[$this->table_element]['type'][$attributeKey]; + $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey]; + $attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey]; + $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; $attributeUnique = $extrafields->attributes[$this->table_element]['unique'][$attributeKey]; - $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$key]; + $attrfieldcomputed = $extrafields->attributes[$this->table_element]['computed'][$attributeKey]; + //$attributeEnabled = $extrafields->attributes[$this->table_element]['enabled'][$attributeKey]; // Similar code than into insertExtraFields - if ($attributeRequired) { + if ($attributeRequired) { // If attribute is "Mandatory", then it is also in database as "Not null", so we must check even if attribute is not 'enabled'. $mandatorypb = false; if ($attributeType == 'link' && $this->array_options["options_".$key] == '-1') { $mandatorypb = true; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 5cce1fe3374..826e19996d7 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -819,6 +819,7 @@ class ExtraFields $result = $this->update_label($attrname, $label, $type, $length, $elementtype, $unique, $required, $pos, $param, $alwayseditable, $perms, $list, $help, $default, $computed, $entity, $langfile, $enabled, $totalizable, $printable, $moreparams, $aiprompt, $emptyonclone, $showintooltip, $personal_data); } if ($result > 0) { + // Add or remove the unique index $sql = ''; if ($unique) { dol_syslog(get_class($this).'::update_unique', LOG_DEBUG); diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 23783ecc184..7a353fd2a35 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -1058,6 +1058,7 @@ class DoliDBMysqli extends DoliDB } } + //print $sql;exit; dol_syslog(get_class($this)."::DDLUpdateField ".$sql, LOG_DEBUG); if (!$this->query($sql)) { return -1; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 2e66235963a..54de7f07c8b 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -268,11 +268,11 @@ if (!getDolGlobalString('MAIN_STORE_COMPUTED_EXTRAFIELDS')) { echo $form->textwithpicto($langs->trans("AIPromptExtrafield"), $texthelp, 1, 'help', 'valignmiddle', 0, 3, 'abc');?>