Merge pull request #9566 from totten/master-19690-layout
[civicrm-core.git] / CRM / Price / Form / Set.php
index c1a87bc643c477cf4d4046fc5c1db9faff3c3bbc..a2127502504835da7276e44b16202ed79108b969 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2016
+ * @copyright CiviCRM LLC (c) 2004-2017
  */
 
 /**
@@ -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;
   }
 
@@ -171,6 +183,8 @@ class CRM_Price_Form_Set extends CRM_Core_Form {
       }
     }
 
+    $this->addElement('text', 'min_amount', ts('Minimum Amount'));
+
     if (CRM_Utils_System::isNull($extends)) {
       $this->assign('extends', FALSE);
     }