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) »
  • Display multi-select/checkbox field in views2
Pages: [1]

Author Topic: Display multi-select/checkbox field in views2  (Read 4060 times)

mariagwyn

  • I post frequently
  • ***
  • Posts: 149
  • Karma: 4
  • CiviCRM version: CiviCRM 3.3.3
  • CMS version: Drupal 6.20
  • MySQL version: 5.2.14
  • PHP version: 5.0.91-50-log
Display multi-select/checkbox field in views2
July 09, 2009, 06:39:31 pm
Brief: multi-select/checkbox fields appear to display in views as a string, not as separate items.  Is there a way to fix this?

Details: I created a custom field 'academic interests', checkbox.  In views, I can call the field, but it displays like this: AgapeBioethicsBuddhist_Ethics.  What I want is this: "Agape, Bioethics, Buddhist Ethics".

Is this possible?  It appears that it is treating output as a string of text, not a list of items.
Thanks,
Maria

Update: on further investigation, this is a problem with other multiselect fields, such as "preferred_contact_method".  It just strings them all together, "123" rather than "1, 2, 3".
« Last Edit: July 09, 2009, 07:31:52 pm by mariagwyn »

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: Display multi-select/checkbox field in views2
July 09, 2009, 09:31:18 pm

i suspect you will need to write (or fix) the handler for multi-selects in the code at: drupal/modules/views/civicrm/* to properly format the text there

we are not too familiar with the code base and cannot help u a lot there. if you do find the relevant file and fix, please do post an issue along with a patch

thanx

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

junix123

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.1
  • CMS version: Drupal 7
  • MySQL version: 5.1.63-cll
  • PHP version: 5.3.9
Re: Display multi-select/checkbox field in views2
June 27, 2012, 06:26:56 pm
Quote from: mariagwyn on July 09, 2009, 06:39:31 pm
Brief: multi-select/checkbox fields appear to display in views as a string, not as separate items.  Is there a way to fix this?

Details: I created a custom field 'academic interests', checkbox.  In views, I can call the field, but it displays like this: AgapeBioethicsBuddhist_Ethics.  What I want is this: "Agape, Bioethics, Buddhist Ethics".

Is this possible?  It appears that it is treating output as a string of text, not a list of items.
Thanks,
Maria

Update: on further investigation, this is a problem with other multiselect fields, such as "preferred_contact_method".  It just strings them all together, "123" rather than "1, 2, 3".

Hi, I have the same problem in Drupal 7 and Views 3, have solve this one?
I hope you can share if it happened you solve this one.

thanks

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Display multi-select/checkbox field in views2
August 05, 2014, 08:49:47 am
I think we've just come up against problem using current stable D7 and Civi 4.4.6. A multiple value CiviCRM field is not being seen as such by Views, and so Views is not providing the relevant formatting options for a multi-value field.

I'm pretty sure others will have been caught by this and may have a found a solution. Any advice or pointers welcome.
Graham Mitchell
http://mc3.coop

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Re: Display multi-select/checkbox field in views2
October 27, 2014, 02:24:18 pm
One option is to use the views_php module. After installing it and becoming user 1 (required to edit php sections), edit your View:

1) Add the multi-value field to the field list if not already there, but tick "Exclude from display"

2) Add a field of type Global: PHP

The values are joined with a chr(1) and have a leading and trailing chr(1) so need a little massaging to display as you want.

Leave the Value Code section blank and in the Output Code section use something like:
Code: [Select]
<?php echo str_replace( chr(1), "<br>", trim( $row->yourfield, chr(1) ) ) ?>
Replace 'yourfield' as needed by looking at the Available Variables section.  Obviously if you want commas, replace the "<br>" with ", " etc.

See https://www.drupal.org/node/1686948

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Display multi-select/checkbox field in views2

This forum was archived on 2017-11-26.