Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-8640

Ability to alter country state lists returned by ajax

    Details

    • Type: New Feature
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.3.6
    • Fix Version/s: 4.1.0
    • Component/s: CiviContribute
    • Labels:
      None

      Description

      We recently had a requirement to add some additional counties (states) to the Irish counties list. Our client wanted to be able include options for Dublin 1, through Dublin 24 (as well as Dublin 6w) in their Irish counties list. These are non-standard counties, although they are quite commonly used in Ireland.

      In order to do this, we added the additional counties to the civicrm_state_province database table. However, they also wanted to be able to order these in a specific order and not the default order that was being returned by CiviCRM. In order to facilitate this, we added an additional hook that gets fired when the country state lists are build. This allows us to intercept the returned list and manipulate it as we see fit. Patch attached.

      Here is our use case for reference.

      /*

      • Implements hook_civicrm_buildStateProvinceForCountry().
        *
      • Reorder the dublin states so that Dublin is at the top and dublin sub
      • states are ordered nicely.
        */
        function ourclient_civicrm_buildStateProvinceForCountry( $countryID, &$states ) {
        // First separate out the Dublin options.
        $topStates = array();
        foreach ($states as $key => $value)
        Unknown macro: { if (preg_match('/Dublin/', $value)) { $topStates[$key] = $value; } else { $otherStates[$key] = $value; } }

        ksort($topStates);
        $states = $topStates + $otherStates;
        }

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              mrfelton Tom Kirkpatrick
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: