Fix : implement separator extrafield - missing check on update
This commit is contained in:
parent
7a16e1b658
commit
ba0963ea7d
@ -2138,13 +2138,18 @@ abstract class CommonObject
|
|||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element."_extrafields (fk_object";
|
||||||
foreach($this->array_options as $key => $value)
|
foreach($this->array_options as $key => $value)
|
||||||
{
|
{
|
||||||
|
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||||
// Add field of attribut
|
// Add field of attribut
|
||||||
$sql.=",".substr($key,8); // Remove 'options_' prefix
|
if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate
|
||||||
|
$sql.=",".$attributeKey;
|
||||||
}
|
}
|
||||||
$sql .= ") VALUES (".$this->id;
|
$sql .= ") VALUES (".$this->id;
|
||||||
foreach($this->array_options as $key => $value)
|
foreach($this->array_options as $key => $value)
|
||||||
{
|
{
|
||||||
|
$attributeKey = substr($key,8); // Remove 'options_' prefix
|
||||||
// Add field o fattribut
|
// Add field o fattribut
|
||||||
|
if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate)
|
||||||
|
{
|
||||||
if ($this->array_options[$key] != '')
|
if ($this->array_options[$key] != '')
|
||||||
{
|
{
|
||||||
$sql.=",'".$this->array_options[$key]."'";
|
$sql.=",'".$this->array_options[$key]."'";
|
||||||
@ -2154,6 +2159,7 @@ abstract class CommonObject
|
|||||||
$sql.=",null";
|
$sql.=",null";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$sql.=")";
|
$sql.=")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::insertExtraFields insert sql=".$sql);
|
dol_syslog(get_class($this)."::insertExtraFields insert sql=".$sql);
|
||||||
|
|||||||
@ -357,7 +357,6 @@ class ExtraFields
|
|||||||
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos,$param='')
|
function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=0,$pos,$param='')
|
||||||
{
|
{
|
||||||
$table=$elementtype.'_extrafields';
|
$table=$elementtype.'_extrafields';
|
||||||
|
|
||||||
// Special case for not normalized table names
|
// Special case for not normalized table names
|
||||||
if ($elementtype == 'member') $table='adherent_extrafields';
|
if ($elementtype == 'member') $table='adherent_extrafields';
|
||||||
elseif ($elementtype == 'company') $table='societe_extrafields';
|
elseif ($elementtype == 'company') $table='societe_extrafields';
|
||||||
@ -385,8 +384,12 @@ class ExtraFields
|
|||||||
$lengthdb=$length;
|
$lengthdb=$length;
|
||||||
}
|
}
|
||||||
$field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL'));
|
$field_desc = array('type'=>$typedb, 'value'=>$lengthdb, 'null'=>($required?'NOT NULL':'NULL'));
|
||||||
|
|
||||||
|
if ($type != 'separate') // No table update when separate type
|
||||||
|
{
|
||||||
$result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
|
$result=$this->db->DDLUpdateField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
|
||||||
if ($result > 0)
|
}
|
||||||
|
if ($result > 0 || $type == 'separate')
|
||||||
{
|
{
|
||||||
if ($label)
|
if ($label)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user