From 544384009257201ff3b92d3d6e61fd701af6e2f8 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Thu, 5 Nov 2020 09:43:34 -0500 Subject: [PATCH] avoid notice / skip validation when deleting --- CRM/Admin/Form/MailSettings.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CRM/Admin/Form/MailSettings.php b/CRM/Admin/Form/MailSettings.php index 76c6874c47..c41cb9b509 100644 --- a/CRM/Admin/Form/MailSettings.php +++ b/CRM/Admin/Form/MailSettings.php @@ -91,7 +91,7 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(['CRM_Admin_Form_MailSettings', 'formRule']); + $this->addFormRule(['CRM_Admin_Form_MailSettings', 'formRule'], $this); } public function getDefaultEntity() { @@ -119,15 +119,21 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { * * @param array $fields * Posted values of the form. + * @param array $files + * Not used here. + * @param CRM_Core_Form $form + * This form. * * @return array * list of errors to be posted back to the form */ - public static function formRule($fields) { + public static function formRule($fields, $files, $form) { $errors = []; - // Check for default from email address and organization (domain) name. Force them to change it. - if ($fields['domain'] == 'EXAMPLE.ORG') { - $errors['domain'] = ts('Please enter a valid domain for this mailbox account (the part after @).'); + if ($form->_action != CRM_Core_Action::DELETE) { + // Check for default from email address and organization (domain) name. Force them to change it. + if ($fields['domain'] == 'EXAMPLE.ORG') { + $errors['domain'] = ts('Please enter a valid domain for this mailbox account (the part after @).'); + } } return empty($errors) ? TRUE : $errors; -- 2.25.1