avoid notice / skip validation when deleting
authordemeritcowboy <demeritcowboy@hotmail.com>
Thu, 5 Nov 2020 14:43:34 +0000 (09:43 -0500)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Thu, 5 Nov 2020 14:43:34 +0000 (09:43 -0500)
CRM/Admin/Form/MailSettings.php

index 76c6874c4718d892e54e99429961cb4b4fc4b48a..c41cb9b509d6483f1ce1821ee53b0b69a2501bfb 100644 (file)
@@ -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;