FIX error management when adding a property with type real

This commit is contained in:
Laurent Destailleur 2019-08-28 12:10:28 +02:00
parent e55b2f8298
commit ed42f59201
2 changed files with 7 additions and 5 deletions

View File

@ -63,11 +63,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (! preg_match('/^(price|boolean|sellist|integer|date|timestamp|varchar|double|text|html)/', $addfieldentry['type']))
if (! preg_match('/^(price|sellist|date|varchar|double|text|html)/', $addfieldentry['type'])
&& ! preg_match('/^(boolean|integer|real|timestamp)$/', $addfieldentry['type']))
{
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2;
}
}

View File

@ -836,7 +836,10 @@ if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj))
if (! $error)
{
$object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry);
if (is_numeric($result) && $result <= 0) $error++;
if (is_numeric($object) && $object <= 0)
{
$error++;
}
}
// Edit sql with new properties