From 8d1d93d77a01e675ab51717781175349ec995c6e Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Thu, 17 Aug 2023 10:41:45 +0200 Subject: [PATCH] display a warning instead of an error if the project_id is a duplicate --- CRM/Twingle/Form/Profile.php | 8 +++++++- CRM/Twingle/Profile.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CRM/Twingle/Form/Profile.php b/CRM/Twingle/Form/Profile.php index 0412b1c..245091f 100644 --- a/CRM/Twingle/Form/Profile.php +++ b/CRM/Twingle/Form/Profile.php @@ -568,7 +568,13 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form { $profile->validate(); } catch (ProfileValidationError $e) { - $this->setElementError($e->getAffectedFieldName(), $e->getMessage()); + switch ($e->getErrorCode()) { + case ProfileValidationError::ERROR_CODE_PROFILE_VALIDATION_FAILED: + $this->setElementError($e->getAffectedFieldName(), $e->getMessage()); + break; + case ProfileValidationError::ERROR_CODE_PROFILE_VALIDATION_WARNING: + CRM_Core_Session::setStatus($e->getMessage(), E::ts('Warning')); + } } } diff --git a/CRM/Twingle/Profile.php b/CRM/Twingle/Profile.php index dddee4e..35373a1 100644 --- a/CRM/Twingle/Profile.php +++ b/CRM/Twingle/Profile.php @@ -296,7 +296,7 @@ class CRM_Twingle_Profile { 2 => $profile->getName() ] ), - ProfileValidationError::ERROR_CODE_PROFILE_VALIDATION_FAILED + ProfileValidationError::ERROR_CODE_PROFILE_VALIDATION_WARNING ); } }