Merge pull request #9174 from colemanw/CRM-19448
[civicrm-core.git] / CRM / Price / Form / Set.php
index c1a87bc643c477cf4d4046fc5c1db9faff3c3bbc..90d9be60fd3ce1e5ac5f25b22fd3927acbcb6826 100644 (file)
@@ -102,6 +102,18 @@ class CRM_Price_Form_Set extends CRM_Core_Form {
     if ($asciiValue >= 48 && $asciiValue <= 57) {
       $errors['title'] = ts("Name cannot not start with a digit");
     }
+    // CRM-16189
+    if (!empty($fields['extends'])
+      && (array_key_exists(CRM_Core_Component::getComponentID('CiviEvent'), $fields['extends'])
+        || array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $fields['extends']))
+    ) {
+      try {
+        CRM_Financial_BAO_FinancialAccount::validateFinancialType($fields['financial_type_id']);
+      }
+      catch (CRM_Core_Exception $e) {
+        $errors['financial_type_id'] = $e->getMessage();
+      }
+    }
     return empty($errors) ? TRUE : $errors;
   }