From f2088a084f4a366e4e06b8a85bdfa79448e0626f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 May 2019 11:53:30 +0200 Subject: [PATCH] Fix error management --- htdocs/contact/card.php | 46 +++++++++++++------------ htdocs/core/class/extrafields.class.php | 1 - 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 9289c156fdb..2ad2e5e2e99 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -377,21 +377,24 @@ if (empty($reshook)) $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; - $result = $object->update($contactid, $user); - - if ($result > 0) { - // Categories association - $categories = GETPOST('contcats', 'array'); - $object->setCategories($categories); - - $object->old_lastname=''; - $object->old_firstname=''; - $action = 'view'; - } - else + if (! $error) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; + $result = $object->update($contactid, $user); + + if ($result > 0) { + // Categories association + $categories = GETPOST('contcats', 'array'); + $object->setCategories($categories); + + $object->old_lastname=''; + $object->old_firstname=''; + $action = 'view'; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; + } } } @@ -500,8 +503,8 @@ else $linkback=''; print load_fiche_titre($title,$linkback,'title_companies.png'); - // Affiche les erreurs - dol_htmloutput_errors(is_numeric($error)?'':$error,$errors); + // Show errors + dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); if ($conf->use_javascript_ajax) { @@ -775,8 +778,8 @@ else $objsoc = new Societe($db); $objsoc->fetch($object->socid); - // Affiche les erreurs - dol_htmloutput_errors($error,$errors); + // Show errors + dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); if ($conf->use_javascript_ajax) { @@ -1073,11 +1076,10 @@ else { $objsoc = new Societe($db); - /* - * Fiche en mode visualisation - */ + // View mode - dol_htmloutput_errors($error,$errors); + // Show errors + dol_htmloutput_errors(is_numeric($error)?'':$error, $errors); dol_fiche_head($head, 'card', $title, -1, 'contact'); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 752818f1520..32313e75d3a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1901,7 +1901,6 @@ class ExtraFields $error_field_required[] = $langs->transnoentitiesnoconv($value); } } - if (in_array($key_type,array('date'))) { // Clean parameters