Answers.Body: <p>This type of problem commonly occurs when any of these is true:</p>
  <ol>
  <li>No default country is set</li>
  <li>No default state is set</li>
  <li>Available countries is not set - list on right-hand side is empty</li>
  <li>Available states is not set - list on right-hand side is empty</li>
  </ol>
  <p>Check your CiviCRM Localisation Settings. Below is a screenshot of a working configuration for a site in Australia that allows both Australia and USA country/state options to be selected.</p>
  <p><a href="https://i.sstatic.net/Cb3y1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Cb3y1.png" alt="CiviCRM Localisation Settings" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T03:42:26.587Z
Answers.Text: Thanks, Justin, for your quick response. I have all of these set in my Localization Settings and the issue still persists. Any thoughts on where to look next?
Answers.UserDisplayName: rgilman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T15:31:57.020Z
Answers.Text: As I describe in my answer below, I found that available countries and available states were the issue but default country or state had no effect, at least in my case.
Answers.UserDisplayName: rgilman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T02:24:51.313Z
Answers.LastActivityDate: 2021-02-23T03:07:26.007Z
Answers.LastEditDate: 2021-02-23T03:07:26.007Z
Answers.UserDisplayName: Justin Freeman - Agileware
Answers.Body: <p>Making sure that Localisation is set is the first step.</p>
  <p>On the form itself, you need to define a country field:</p>
  <p><a href="https://i.sstatic.net/GLi55.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GLi55.png" alt="Country Field" /></a></p>
  <p>and then the State/Province Field. In the State Field be sure you are linking to the Country Field:</p>
  <p><a href="https://i.sstatic.net/zNVOg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zNVOg.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T15:35:15.613Z
Answers.Text: Thanks, Kevin, for your reply. As I describe in my answer below, I found that the CiviCRM Country field made no difference since I have only one Country/State pair in the form.
Answers.UserDisplayName: rgilman
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-21T17:57:20.327Z
Answers.Text: @kevin-cristiano  So I have the Country select above the State/Province select, and I have tried the CiviCRM Country slug into the CiviCRM Country field (with and without %%) but the State/Province select still shows ALL states/provinces in the list and does not limit it to the selected country. Am I missing something?
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-22T18:19:16.620Z
Answers.Text: Not that I know of.   I think without % is better.  I'd see if you have localization set up.  Even if you want all countries and states/provinces try that first.
Answers.UserDisplayName: Kevin Cristiano
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T13:04:47.313Z
Answers.LastActivityDate: 2020-10-09T13:04:47.313Z
Answers.UserDisplayName: Kevin Cristiano
Answers.Body: <p>I have it working and, at least in my case, the issue is with the handling of available countries and available states as rbaugh describes in <a href="https://github.com/mecachisenros/cf-civicrm/issues/177" rel="nofollow noreferrer">this github issue</a>. Essentially, if you leave the right-hand box empty to include all countries (as the CiviCRM note directs), none of the states are loaded. Loading all of the countries into both right-hand boxes works.</p>
  <p>Commenting out the foreach loop from lines 293 to 297 in <a href="https://github.com/mecachisenros/cf-civicrm/blob/fe03d5312c0622bbaeeaf3c2b2d730fdea0dd7cb/includes/class-civicrm-caldera-forms-helper.php#L293" rel="nofollow noreferrer">cf-civicrm/includes/class-civicrm-caldera-forms-helper.php</a> allows the fields to work in the form with the available countries right-hand box empty (with the available states empty as well).</p>
  <p>My usage is worldwide. I need all the countries so this hack works for me but it looks like the logic around that foreach loop needs some refinement.</p>
  <p>Along the way I did some tests.</p>
  <ul>
  <li>It works fine with no default country or state. Only the available countries and available states mattered. (See Justin Freeman's reply above.)</li>
  <li>Since I have only one pair of Country/State fields, the CiviCRM Country field in the State field parameter list has no effect. (See Kevin Cristiano's reply above.)</li>
  </ul>
  <p>I'll report what I'm finding on the cf-civicrm github site.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-09T15:29:48.610Z
Answers.LastActivityDate: 2020-10-09T15:29:48.610Z
Answers.UserDisplayName: rgilman
Body: <p>I've just started working with the cf-civicrm plugin so I may be missing something simple.</p>
  <p>I can't get the CiviCRM State/Province select field to fill. I tested it using the &quot;CiviCRM Contact and Address&quot; form template after running into the issue on a form I was building. No luck. The field just returns N/A for every country I've tried.</p>
  <p>My experience has some parallels to <a href="https://github.com/mecachisenros/cf-civicrm/issues/178" rel="nofollow noreferrer">this github issue</a> but the fix that worked for rbaugh isn't working for me.</p>
  <p>Questions, tip and pointers about how to resolve this would be most welcome.</p>
  <p>Thanks!</p>
  
Tags: <caldera-forms>
Title: cf-civicrm State/Province field dropdown not populating after country is chosen
ThreadText: # cf-civicrm State/Province field dropdown not populating after country is chosen
  
  (Asked by: username_0 on 2020-10-08)
  
  I've just started working with the cf-civicrm plugin so I may be missing something simple.
  
  I can't get the CiviCRM State/Province select field to fill. I tested it using the "CiviCRM Contact and Address" form template after running into the issue on a form I was building. No luck. The field just returns N/A for every country I've tried.
  
  My experience has some parallels to [this github issue](https://github.com/mecachisenros/cf-civicrm/issues/178) but the fix that worked for rbaugh isn't working for me.
  
  Questions, tip and pointers about how to resolve this would be most welcome.
  
  Thanks!
  
  **Tags:** caldera-forms
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2020-10-09. Score: 5
  
  This type of problem commonly occurs when any of these is true:
  
  1. No default country is set
  2. No default state is set
  3. Available countries is not set - list on right-hand side is empty
  4. Available states is not set - list on right-hand side is empty
  
  Check your CiviCRM Localisation Settings. Below is a screenshot of a working configuration for a site in Australia that allows both Australia and USA country/state options to be selected.
  
  [![CiviCRM Localisation Settings](https://i.sstatic.net/Cb3y1.png)](https://i.sstatic.net/Cb3y1.png)
  
  > **Comments:**
  > **username_0**: Thanks, username_1, for your quick response. I have all of these set in my Localization Settings and the issue still persists. Any thoughts on where to look next?  
  > **username_0**: As I describe in my answer below, I found that available countries and available states were the issue but default country or state had no effect, at least in my case.  
  
  ---
  
  ### Answer by username_2 on 2020-10-09. Score: 2
  
  Making sure that Localisation is set is the first step.
  
  On the form itself, you need to define a country field:
  
  [![Country Field](https://i.sstatic.net/GLi55.png)](https://i.sstatic.net/GLi55.png)
  
  and then the State/Province Field. In the State Field be sure you are linking to the Country Field:
  
  [![enter image description here](https://i.sstatic.net/zNVOg.png)](https://i.sstatic.net/zNVOg.png)
  
  > **Comments:**
  > **username_0**: Thanks, username_2, for your reply. As I describe in my answer below, I found that the CiviCRM Country field made no difference since I have only one Country/State pair in the form.  
  > **username_3**: @username_2-username_2  So I have the Country select above the State/Province select, and I have tried the CiviCRM Country slug into the CiviCRM Country field (with and without %%) but the State/Province select still shows ALL states/provinces in the list and does not limit it to the selected country. Am I missing something?  
  > **username_2**: Not that I know of.   I think without % is better.  I'd see if you have localization set up.  Even if you want all countries and states/provinces try that first.  
  
  ---
  
  ### Answer by username_0 on 2020-10-09. Score: 2
  
  I have it working and, at least in my case, the issue is with the handling of available countries and available states as rbaugh describes in [this github issue](https://github.com/mecachisenros/cf-civicrm/issues/177). Essentially, if you leave the right-hand box empty to include all countries (as the CiviCRM note directs), none of the states are loaded. Loading all of the countries into both right-hand boxes works.
  
  Commenting out the foreach loop from lines 293 to 297 in [cf-civicrm/includes/class-civicrm-caldera-forms-helper.php](https://github.com/mecachisenros/cf-civicrm/blob/fe03d5312c0622bbaeeaf3c2b2d730fdea0dd7cb/includes/class-civicrm-caldera-forms-helper.php#L293) allows the fields to work in the form with the available countries right-hand box empty (with the available states empty as well).
  
  My usage is worldwide. I need all the countries so this hack works for me but it looks like the logic around that foreach loop needs some refinement.
  
  Along the way I did some tests.
  
  * It works fine with no default country or state. Only the available countries and available states mattered. (See username_1 Freeman's reply above.)
  * Since I have only one pair of Country/State fields, the CiviCRM Country field in the State field parameter list has no effect. (See username_2 username_2's reply above.)
  
  I'll report what I'm finding on the cf-civicrm github site.
  
  
  ---
  
  