CRM-3264 Profile form does not restrict states by country

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.2.0
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      When using the profile retrieved with crm_uf_get_profile_html_by_id(), with a profile with country and state fields, all of the states are shown. While the CiviCRM edit page attempts to restrict the state list with AJAX,

      I used a simpler jquery solution in a custom Drupal module. I don't think that CiviCRM uses, jquery, so I don't know if this will be useful to CiviCRM.

      Here's the Drupal solution, the jquery is attached.

      <code>
      function _myexample_civicrm_get_profile_html($contact_id, $profile_id) {
      $path = drupal_get_path('module', 'civicrm') .'/../';
      require_once($path .'api/UFGroup.php');
      require_once($path .'CRM/Core/DAO/StateProvince.php');

      // Include a jquery setting that maps states to countries.
      $object =& new CRM_Core_DAO_StateProvince;
      $object->find();
      $states = array();
      while ($object->fetch())

      { $states[$object->id] = $object->country_id; }

      drupal_add_js(array('states' => $states), 'setting');
      // Include the jquery to limit the state select box by country.
      drupal_add_js(drupal_get_path('module', 'myexample') .'/civicrm-state.js');

      return crm_uf_get_profile_html_by_id($contact_id, $profile_id, CRM_Core_Action::UPDATE, false, true);
      }
      </code>

        Attachments

          Activity

          [CRM-3264] Profile form does not restrict states by country
          Donald A. Lobo added a comment -


          Can u create a unit test case for this and fix as needed

          Donald A. Lobo added a comment -


          We plan on upgrading the profiles and toher forms to the dojo widget in a 2.x release

          David Greenberg added a comment -

          Implementing jquery-based state-picker for core forms and profiles.

          Donald A. Lobo added a comment -


          This should be fixed with our new jquery based state/country selector

          Sunil Pawar added a comment -

          Verified in r18956

          Kurund Jalmi added a comment -

          Batch move to verification

          Amiteshwar Prasad added a comment -

          Verified with r23009

            People

            • Assignee:
              Amiteshwar Prasad
              Reporter:
              Doug Green

              Dates

              • Created:
                Updated:
                Resolved: