CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • how to limit a "state" profile field options to one country?
Pages: [1]

Author Topic: how to limit a "state" profile field options to one country?  (Read 978 times)

minbori

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 2
  • CiviCRM version: 4.0.8
  • CMS version: Joomla 2.5.24
  • MySQL version: 5.5.37
  • PHP version: 5.3.29
how to limit a "state" profile field options to one country?
September 06, 2011, 03:42:09 am
Greetings all, I apologize in advance if this is a n00b question but it's got me stumped.

Here's the scenario:  I've got an event for which I have a Custom Profile defined and shown on the registration so I can gather extra event-relevant information on the participant.  One of the Custom Data fields is "U.S. Voting State", because I need to know which US state they're eligible to vote in.  I would like to have this field as a drop-down single select limited to the 50 US states.

However, as this is an international event, the participant might LIVE anywhere in the world.  So my CiviCRM global settings are set to contain all countries and and their states/counties/provinces, with U.S. being defined as the "default" country for any form.

If I create a custom data field, I can only create a select on either "state" or "country", but not combine them. So the state selector in the form produces a list of ALL states in ALL nations -- I want it limited to just the 50 US states.

Options I've considered: 
-- making an alphanumeric custom select list only allows me 10 select options. (plus I don't want to have to retype all 50 state names  :P )
-- making a simple alphanumeric text entry box and making the participant enter it by hand (I'd really prefer to standardize the entries so searches and reports will be cleaner)

Ideas, or something simple I've missed?  ::)

minbori

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 2
  • CiviCRM version: 4.0.8
  • CMS version: Joomla 2.5.24
  • MySQL version: 5.5.37
  • PHP version: 5.3.29
Re: how to limit a "state" profile field options to one country?
September 06, 2011, 03:52:19 am
One follow-up:  I did just realize that I can create a custom Multiple Choice Option list that is longer than 10 items...but as I wrote before, I'd really prefer to use the standard inbuilt CiviCRM state listings, and I'd sooooo NOT prefer to have to create the 50-item state list by hand !  8)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: how to limit a "state" profile field options to one country?
September 06, 2011, 07:08:54 am

a couple of options:

1. store that informaton in a :U.S. Voting State: location type. In the profile u can include both state and country for that location type

2. Create a select field and use the hook:

http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmcustomFieldOptions

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

minbori

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 2
  • CiviCRM version: 4.0.8
  • CMS version: Joomla 2.5.24
  • MySQL version: 5.5.37
  • PHP version: 5.3.29
Re: how to limit a "state" profile field options to one country?
September 06, 2011, 08:11:22 am
Thanks so much for the response.  I hadn't thought of using a location type!  I think that will be easier than implementing the hook, as I'm only just getting started in the "extending CiviCRM" realm and am still figuring out how hooks work for Joomla  ::) (though maybe this is a great starter project for me to try it out on!)

minbori

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 2
  • CiviCRM version: 4.0.8
  • CMS version: Joomla 2.5.24
  • MySQL version: 5.5.37
  • PHP version: 5.3.29
Re: how to limit a "state" profile field options to one country?
September 06, 2011, 09:04:10 am
Thanks Lobo, worked a treat! Set up a USVoting location type, and added both USVoting:Country and USVoting:State to the Custom Profile.  As United States is the default country, the registration form populates that automatically and loads the US states in the "state" select box.  Then I just "hid" the USVoting:Country select box using CSS.

Now off to learn more about hooks...  ;)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • how to limit a "state" profile field options to one country?

This forum was archived on 2017-11-26.