fixes for CRM-13824
authorkurund <kurund@civicrm.org>
Mon, 25 Nov 2013 14:55:29 +0000 (20:25 +0530)
committerkurund <kurund@civicrm.org>
Mon, 25 Nov 2013 14:55:29 +0000 (20:25 +0530)
----------------------------------------
* CRM-13824: Fatal error on contribution page
  http://issues.civicrm.org/jira/browse/CRM-13824

CRM/Contact/Form/Edit/Address.php

index 6039e193bf8559d22bf5cb2f149ffd1feb1cdd25..e8a944f5891e712b56c06ced90000d1a732f129e 100644 (file)
@@ -450,28 +450,28 @@ class CRM_Contact_Form_Edit_Address {
         $stateID = CRM_Utils_Array::value(0, $form->getElementValue($stateElementName));
       }
     }
-    if ($countryID &&
-      isset($form->_elementIndex[$stateElementName])
-    ) {
-      $stateSelect = &$form->addElement('select',
-        $stateElementName,
-        $stateTitle,
-        array(
-          '' => ts('- select -')) +
-        CRM_Core_PseudoConstant::stateProvinceForCountry($countryID)
-      );
+
+    if (isset($form->_elementIndex[$stateElementName])) {
+      if ($countryID) {
+        $stateProvinces = CRM_Core_PseudoConstant::stateProvinceForCountry($countryID);
+      }
+      else {
+        $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
+      }
+
+      $stateSelect = & $form->addElement('select', $stateElementName, $stateTitle,
+        array('' => ts('- select -')) + $stateProvinces);
     }
-    if ($stateID &&
-      isset($form->_elementIndex[$stateElementName]) &&
-      isset($form->_elementIndex[$countyElementName])
-    ) {
-      $form->addElement('select',
-        $countyElementName,
-        ts('County'),
-        array(
-          '' => ts('- select -')) +
-        CRM_Core_PseudoConstant::countyForState($stateID)
-      );
+
+    if (isset($form->_elementIndex[$stateElementName]) && isset($form->_elementIndex[$countyElementName])) {
+      if ($stateID) {
+        $counties = CRM_Core_PseudoConstant::countyForState($stateID);
+      }
+      else {
+        $counties = CRM_Core_PseudoConstant::country();
+      }
+
+      $form->addElement('select', $countyElementName, ts('County'), array('' => ts('- select -')) + $counties);
     }
 
     // CRM-7296 freeze the select for state if address is shared with household