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) »
  • Populating the advmultiselect field
Pages: [1]

Author Topic: Populating the advmultiselect field  (Read 3692 times)

dragontree

  • Guest
Populating the advmultiselect field
December 03, 2009, 07:07:54 am
I'm using several custom advmultiselect field for my contacts. But I cant figure out how to add the default values needed. I'm using the customFieldOptions hook to add the "unselected" values, that works fine.
But after I choose some values and save and then edit again the saved values are not in the "selected" side.
In advmultiselect.php there are something about "selected" options. I just dont understand how it works.

1. So, are the "selected" values supposed to be filled automatically from the database?

2. Or do I have to fill them the same way I'm populating the "unselected" values? If so, then how should the $options array look like in the hook?

dragontree

  • Guest
Re: Populating the advmultiselect field
December 08, 2009, 03:50:46 am
It seems that only the values that I add with the hook are not shown in the "selected" box. The ones I defined when I created the field are working just fine.

And if I add the cutom value to the civicrm_option_value table, it works.

So it seems that I have to add all the values to that table...not sure where it should be done though.
« Last Edit: December 08, 2009, 06:47:26 am by dragontree »

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: Populating the advmultiselect field
December 08, 2009, 08:15:48 am

the customFieldOptions hooks were designed and tested on select/checkbox/radio fields.

for advmultiselect, your best bet might be to check what the default values are set to in the form code. that basically lets the element decide whether an option is selected or not

ping us on irc if u need more help

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

dragontree

  • Guest
Re: Populating the advmultiselect field
December 09, 2009, 05:53:07 am
Its not that easy to get a reply on irc...

Problem is that I'm not even sure where to start.
I guess that the default values are set in the setDefaultValues() function but I can't seem to figure it out in which file it is.

dragontree

  • Guest
Re: Populating the advmultiselect field
December 09, 2009, 07:57:39 am
Filed an issue: http://issues.civicrm.org/jira/browse/CRM-5524

dragontree

  • Guest
Re: Populating the advmultiselect field
December 18, 2009, 02:17:00 am
The issue is marked as solved, but something is still not working. (3.1 beta 1 and beta 2)

The options array looks fine (see attached image) but the options dont show up on the select box correctly.
They look like this:
Quote
<option value="0"/>
<option value="1"/>
<option value="2"/>

dragontree

  • Guest
Re: Populating the advmultiselect field
December 27, 2009, 10:03:44 pm
bump

If this is a low priority issue for 3.1, could someone point me in the right direction where to look to fix it.
I really need this.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Populating the advmultiselect field
December 28, 2009, 11:58:07 am
I'm not too up on this code - and some folks are on holiday break. BUT... you checking the two 'diffs' for the related / fixed hook issue might give you some clues as to whether there's still a problem w/ the code or if you need to tweak what you're passing to the hook:

http://fisheye2.atlassian.com/viewrep/CiviCRM/trunk/CRM/Utils/Hook.php?r1=25405&r2=25461

I'd particularly look here since lobo has added an example to the 'sample' module:
http://fisheye2.atlassian.com/viewrep/CiviCRM/trunk/drupal/civitest.module.sample?r1=25405&r2=25461
Protect your investment in CiviCRM by  becoming a Member!

dragontree

  • Guest
Re: Populating the advmultiselect field
December 28, 2009, 12:15:16 pm
I checked these diffs and made the changes in my installation and my hook code. I just get the feeling that there is something more to that...

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: Populating the advmultiselect field
December 28, 2009, 06:54:26 pm

i just tried this in the latest 3.1 on my labtop and it worked as advertised

not sure what is happening in your install and why. if u can catch me on IRC that will help. however i'm on vacation this week and dont have any regular hours :)

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

dragontree

  • Guest
Re: Populating the advmultiselect field
December 29, 2009, 10:15:55 pm
Got it working thanks to lobo.
The only thing is that I'm not really sure how  :D

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Populating the advmultiselect field

This forum was archived on 2017-11-26.