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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Pre-populated drop down in profile based on sql
Pages: [1]

Author Topic: Pre-populated drop down in profile based on sql  (Read 3300 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Pre-populated drop down in profile based on sql
March 06, 2009, 05:27:09 am
Hi,

We have a requirement for a field in a profile to be a drop down pre-populated based on sql criteria

(eg. select companies where custom field is 1)

What is the best way to attack this?
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

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: Pre-populated drop down in profile based on sql
March 06, 2009, 06:34:17 am

In 2.2, there is a new hook: hook_civicrm_customFieldOptions which you can use to extend / modify a custom field options which you can potentially use

however this hook does not really work if it also depends on choices made by the user on the same page (since the form is rendered before the user has entered any input)

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Pre-populated drop down in profile based on sql
March 06, 2009, 01:08:29 pm
OK - so I guess ideally I would be able to add a relationship field to a profile here

http://sandbox.civicrm.org/civicrm/admin/uf/group/field?reset=1&action=add&gid=1

which would look like this

http://sandbox.civicrm.org/civicrm/contact/view/rel?cid=101&action=add&reset=1

That might be worth adding into civiCRM - although perhaps not in time for my use.

In this case the organisations are already in civi and when people sign up they pick their own organisation to establish the relationship
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

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Pre-populated drop down in profile based on sql
March 06, 2009, 02:56:37 pm
Those links aren't working for me.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Pre-populated drop down in profile based on sql
March 06, 2009, 03:02:15 pm
The sandbox is now running trunk (development) code - so change those links to the 2.2 demo and they should work.
Protect your investment in CiviCRM by  becoming a Member!

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Pre-populated drop down in profile based on sql
March 06, 2009, 05:26:07 pm
The second one is broken but I assumed that it would be temporary. I think it's just an ugly error message because the data isn't there
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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Pre-populated drop down in profile based on sql
March 11, 2009, 01:49:35 am
Hi,

Lobo, that hook doesn't actually make sense yet I don't think ???? as the task at this stage is not to render a custom field but to show a standard field on a profile the same way it appears on the edit contact page.

ie. I'm looking to add the 'current employer' field to a custom profile but I want it to show as a dojo drop-down box like it does on this screen: http://sandbox.civicrm.org/civicrm/contact/add?reset=1&action=update&cid=101

So it would show instead of the text field on this screen
http://sandbox.civicrm.org/civicrm/admin/uf/group?action=preview&id=4&reset=1&field=0&context=field

It seems to me the hook you suggested relates to items in the civicrm_custom_field table?
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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Pre-populated drop down in profile based on sql

This forum was archived on 2017-11-26.