Index: CRM/Core/BAO/UFGroup.php
===================================================================
--- CRM/Core/BAO/UFGroup.php	(révision 38502)
+++ CRM/Core/BAO/UFGroup.php	(copie de travail)
@@ -1540,8 +1540,22 @@
                                                               'address_options', true, null, true );
         
         if ( substr($fieldName,0,14) === 'state_province' ) {
-            $form->add('select', $name, $title,
-                       array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(), $required);
+            // CRM-9520 When there are errors in a submitted form, it's hard to fetch the country
+            // value (especially if 'on behalf of'), so in that case, list all state/provinces
+            $config = CRM_Core_Config::singleton( );
+            $stateProvinces = array();
+            $country = $config->defaultContactCountry;
+            if ( !empty( $form->_submitValues ) ) {
+              unset($country);
+            }
+
+            if ( !in_array( $mode, array( CRM_Profile_Form::MODE_EDIT, CRM_Profile_Form::MODE_SEARCH ) ) && $country ) {
+                $stateProvinces = CRM_Core_PseudoConstant::stateProvinceForCountry($country);
+            } else {
+                $stateProvinces = CRM_Core_PseudoConstant::stateProvince();
+            }
+
+            $form->add('select', $name, $title, array('' => ts('- select -')) + $stateProvinces, $required);
         } else if ( substr($fieldName,0,7) === 'country' ) {
             $form->add('select', $name, $title, 
                        array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required);

