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 Drupal Modules (Moderator: Donald Lobo) »
  • Bug? Drupal views display values of CiviCRM select fields, rather than labels
Pages: [1]

Author Topic: Bug? Drupal views display values of CiviCRM select fields, rather than labels  (Read 1495 times)

spidersilk

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
    • Freeform Solutions
  • CiviCRM version: Several, on different sites
  • CMS version: Drupal (6 and 7)
  • MySQL version: Varies
  • PHP version: Varies
Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 07, 2014, 09:07:30 am
I've run into an issue (possible bug?) on a client site where Drupal views are displaying CiviCRM data in an inconsistent and unhelpful way.

When pulling data from a CiviCRM custom field, if the field is set up to use radio buttons or checkboxes has never been changed since it was set up, it will show the label, rather than the value, which is generally as it should be. But if it's a select list it has been changed in any way, for example by editing the label or providing a translation into another language, it will show the value instead! Which is a problem.

Example: let's say you have set of options as follows:
  • Label: "Federal government", value: "federal"
  • Label: "Provincial government", value: "provincial"
  • Label: "Municipal government", value: "municipal"
If you set up the field as checkboxes or radio buttons, and then use the field in a view initially, without having modified it, the view will display (if the first option is selected) "Federal government". But if you set it up as a select list modify it in any way, it will forever afterward display "federal" instead.

Why not just use the text you want as the value, you may be wondering? Because if you're creating a multilingual site, that doesn't work - the labels are translatable, but the values aren't. So to use our example above, if you have:
  • English label: "Federal government", French label: "Gouvernement fédéral", value: "federal"
  • English label: "Provincial & territorial governments", French label: "Gouvernements provinciaux et territoriaux", value: "provincial"
  • English label: "Municipal government", French label: "Gouvernements municipaux", value: "municipal"
You can see here that there's a bigger problem - if the site is being viewed in French, you don't want it to just say "provincial" where it should say "Gouvernements provinciaux et territoriaux".

In some cases, an obvious workaround would be to use make the field in question a checkbox or radio button field instead of a select, but that's not always practical - with a list longer than the above example, buttons and checkboxes can get unwieldy pretty quickly. Plus there's no reason that data from select lists should be being handled differently from the others in the first place, as far as I can see.  Edit: I had initially thought this was a matter of select lists as compared to checkboxes and radio buttons, but further experimenting showed that it as actually whether or not the field had ever been edited after its creation. It was just coincidence that on the particular site I encountered this on, a couple of select lists had been edited (to add the French translations), but the radio button and checkbox fields hadn't yet as of when I originally posted this.

I'm fairly sure this is a bug, but as per the instructions at https://civicrm.org/bug-reporting, I'm posting it here first, before filing it with the bug tracker, to see if anyone else has any input to offer.
« Last Edit: September 17, 2014, 09:46:07 am by spidersilk »
Web developer at Freeform Solutions - your not-for-profit technology support

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 07, 2014, 09:13:19 am
Seems likely related to
https://issues.civicrm.org/jira/browse/CRM-15025
or https://issues.civicrm.org/jira/browse/CRM-12956
Try asking your question on the new CiviCRM help site.

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: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 07, 2014, 12:37:03 pm
in a (slightly) related matter - we are looking in to what it will take to provide a formatter within the Views Field so one can opt to show either Key or Value in the way that Views offers this for Drupal select fields
but what confuses me here is that in the civi fields I am testing with, which are radio buttons, I do see the label when I would rather see the value - and the OP seems to be describing the opposite but there is every chance that i am using a civi that has patches backported knowing Eileen.
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

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 08, 2014, 04:20:19 am
Just posted this http://forum.civicrm.org/index.php/topic,33791.0.html about Views displaying values instead of labels on a custom country field.

It does seem to be pretty inconsistent.
Graham Mitchell
http://mc3.coop

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: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 08, 2014, 02:46:12 pm
and i replied there that i am still seeing countries as the 'label' so ... two against one ... i will have a dig and try and figure if we have some special sauce here that has been contributed back (we are pretty good at getting our fixes back in) but that perhaps hasn't been included in the latest release.
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

spidersilk

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
    • Freeform Solutions
  • CiviCRM version: Several, on different sites
  • CMS version: Drupal (6 and 7)
  • MySQL version: Varies
  • PHP version: Varies
Re: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 11, 2014, 02:46:37 pm
Quote from: Coleman Watts on August 07, 2014, 09:13:19 am
Seems likely related to
https://issues.civicrm.org/jira/browse/CRM-15025
or https://issues.civicrm.org/jira/browse/CRM-12956
I checked out both of those... The second one is supposed to have been fixed as of version 4.4.4, so that wouldn't be affecting this site. With the first, there was a link to a patch in the comments (https://github.com/civicrm/civicrm-drupal/pull/154), but I tried applying it, and it didn't help.
Web developer at Freeform Solutions - your not-for-profit technology support

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 14, 2014, 02:42:03 am
What we are seeing is that if the Views field is set up such that is uses the same label as the custom CiviCRM field, then the label gets displayed rather than the value, but if we use no label in Views, we see that the value gets displayed. And if you use a different label, then nothing gets displayed.

We also noted a very curious situation where we had a multi-select country custom field set up, which we called 'Country', and had another single select country custom field, also called 'Country'. The single select field was used in a View, but only displayed the 4 digit code. The multi-select field was not used in the View. However, when looking at the queries generated by the view, the multi-select custom field was being referred to.

We also saw a notice:

Notice: Undefined index: 07 in CRM_Core_BAO_CustomField::getDisplayValueCommon() (line 1318 of /data/www/html/drupal/sites/all/modules/civicrm/CRM/Core/BAO/CustomField.php).

Changing the name of the multi-select country field to something else solved the problem. Sounds like labels are being treated as something more important than just labels.

Graham Mitchell
http://mc3.coop

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: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 14, 2014, 11:44:21 am
with the risk we are still talking at cross-purposes, we have had the need to come up with a new Views Field formatter so that for fields with Options we can now choose between 'Value' or 'Label' - hopefully I will get this published early next week.
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

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Bug? Drupal views display values of CiviCRM select fields, rather than labels
August 14, 2014, 10:50:47 pm
Thanks petednz
Maybe when you have something ready you could post in this thread with a link and we'll be happy to give it a spin.

Best wishes
Graham
Graham Mitchell
http://mc3.coop

spidersilk

  • I’m new here
  • *
  • Posts: 10
  • Karma: 0
    • Freeform Solutions
  • CiviCRM version: Several, on different sites
  • CMS version: Drupal (6 and 7)
  • MySQL version: Varies
  • PHP version: Varies
Re: Bug? Drupal views display value of edited CiviCRM fields, rather than label
September 17, 2014, 09:53:10 am
Still wrestling with this issue. I updated the original post to reflect that we've since discovered that it's not a matter of select lists vs. radio buttons or checkboxes, but of whether the field has ever been edited (for example, to add French translations of the labels).

This suggests that it is an instance of the issue described here: https://issues.civicrm.org/jira/browse/CRM-15025, which is supposed to be fixed in 4.4.7, but the fix they linked to in that issue (https://github.com/civicrm/civicrm-drupal/pull/154) made it worse, not better. I still didn't get the French labels, plus the views provided fewer results than before.

BTW, I tried to replicated this on the CiviCRM demo site as the bug reporting guidelines say to do, but couldn't because it doesn't provide access to Views. We did replicate it in an internal test environment, though.
Web developer at Freeform Solutions - your not-for-profit technology support

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Bug? Drupal views display values of CiviCRM select fields, rather than labels

This forum was archived on 2017-11-26.