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 get a country field to be set to my default country already on page load
Pages: [1]

Author Topic: how to get a country field to be set to my default country already on page load  (Read 2086 times)

Sean Madsen

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 5
  • CiviCRM implementer/developer
    • Bikes Not Bombs
  • CiviCRM version: 4.6
  • CMS version: Drupal 7
how to get a country field to be set to my default country already on page load
May 26, 2009, 08:09:32 pm
I have a profile with a country field and a state field. In my Civi installation I have a default country set and I have all countries enabled.

The current behavior after page load of the profile fields is: the country select has nothing selected and offers all countries as options, with my default country listed first; the state select has nothing selected displays all states for all countries; then after selecting a country, the state select changes to only offer the the states of the selected country as options.

The behavior I desire is: after page load the country select has my default country selected

Why? ...usability. Some people are getting confused when they open the state select before opening the country. Also the javascript to do the state option filter can take upwards of 10 seconds on low-end machines.

Does anyone know how to get my default country to automatically become selected after the profile page loads?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: how to get a country field to be set to my default country already on page load
May 26, 2009, 08:16:34 pm
HI - Are you able to update your profile with CiviCRM & CMS versions?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: how to get a country field to be set to my default country already on page l
May 27, 2009, 05:34:26 am
Hey Sean
the reason eileen is asking you to update your forum profile with your civi and cms versions is so that we can easily see what civi version you are working on. i believe the behavior you are looking for is indeed the default behavior in civi 2.2 (you can go to the demo site and check it out; worked for me).

if you are not on 2.2, tell us which version you're on.

Sean Madsen

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 5
  • CiviCRM implementer/developer
    • Bikes Not Bombs
  • CiviCRM version: 4.6
  • CMS version: Drupal 7
Re: how to get a country field to be set to my default country already on page load
May 27, 2009, 06:16:00 am
Sorry, I should have said that before: I'm running CiviCRM 2.2.0 on Drupal 6.9, testing with Firefox 3

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: how to get a country field to be set to my default country already on page l
May 27, 2009, 06:45:33 am
hmm, sorry, i was looking at demo site preview of a profile and it was selecting default country (or maybe it was cached in my browser). anyway, going to the live profile on demo and it is using same behavior as you describe.

i wonder if this is a bug.

i just looked at the standalone code for the profile i set on the demo site and in that code i see:
   <option value="1228" selected="selected">United States</option>

however, when i go to the profile itself (http://drupal.demo.civicrm.org/civicrm/profile?reset=1&id=1&gid=1)
the default country is not selected (tested in Safari 3 Mac and Firefox 2 Mac). Based on the standalone code, it seems this in fact should be the correct behavior. Searched around on jira issues and did not see a match for this if it is a bug.

will wait for a developer to weigh in on this before i submit it as a bug...

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 get a country field to be set to my default country already on page load
May 27, 2009, 07:24:24 am

Note that we dont set default values during search (it is a search after all)

http://drupal.demo.civicrm.org/civicrm/profile/create?reset=1&id=1&gid=1

that has the country set properly

if you'd like default values set during search, you can potentially do it via the buildForm hook

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

Sean Madsen

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 5
  • CiviCRM implementer/developer
    • Bikes Not Bombs
  • CiviCRM version: 4.6
  • CMS version: Drupal 7
Re: how to get a country field to be set to my default country already on page load
May 27, 2009, 07:50:51 am
The behavior of the country field on the page lobo provided is exactly the behavior I'm looking for.
http://drupal.demo.civicrm.org/civicrm/profile/create?reset=1&id=1&gid=1

...but I don't see what is different about my settings that makes the country field load without being set
http://crm.bikesnotbombs.org/civicrm/event/register?id=2&reset=1

Any ideas for what setting I might try changing?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: how to get a country field to be set to my default country already on page load
May 27, 2009, 09:25:46 pm
I think Lobo was saying it isn't set for Search use of a profile - the link he gave you was to the CREATE usage and it was set
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • how to get a country field to be set to my default country already on page load

This forum was archived on 2017-11-26.