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) »
  • Option Group customization
Pages: [1]

Author Topic: Option Group customization  (Read 872 times)

routinet

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: Generally up-to-date
  • CMS version: Joomla
  • MySQL version: MySQL 5+
  • PHP version: PHP 5+
Option Group customization
March 06, 2014, 06:55:21 am
I'm trying to create an option group for a custom data field.  It needs to be a multi-select dropdown.  An example of the HTML it should generate:

Code: [Select]
<select>
  <optgroup label="Accommodations">
    <option value="Bed & Breakfasts">Bed &amp; Breakfasts</option>
    <option value="Camping">Camping</option>
  </optgroup>
  <optgroup label="Arts & Crafts">
    <option value="Artisans">Artisans</option>
    <option value="Artists">Artists</option>
  </optgroup>
</select>

I tried using [Administer -> System Settings -> Option Groups], but any group I create there is not available from the "Multiple Choice Option Sets" dropdown when creating the custom field.  How can I implement this kind of selector?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Option Group customization
March 06, 2014, 06:59:51 am
CiviCRM forms are generated with QuickForm 1.x which does not support optgroups.
I have just added a bit of a hack to work around this for the upcoming 4.5 release. So you will be able to do it soon (although it's not the most elegant thing in the world). Check back in a few weeks for an update, maybe it will improve before the release.
Try asking your question on the new CiviCRM help site.

routinet

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: Generally up-to-date
  • CMS version: Joomla
  • MySQL version: MySQL 5+
  • PHP version: PHP 5+
Re: Option Group customization
March 06, 2014, 07:18:14 am
Thanks for the quick attention.  Good and bad news, I guess.   :-\  I'll look for it in 4.4.5, and hope the client doesn't feel the optgroups are necessary in the meantime.

How can I address the other unexpected behavior I found when dealing with option group customizations?  When I create a group through the interface, it does not appear in the dropdown.  If I go into the db and manually assign it, it seems to work as expected, but it isn't selectable until I take that step.  Even worse, when I did assign it, the field's previously selected option group was deleted from the db.  Is this expected behavior?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Option Group customization
March 06, 2014, 07:24:58 am
I'm not exactly sure what you mean - normally when you create a custom field you create the associated option list on the same screen. Is there some reason you don't want that?

PS To avoid false expectations - I said "4.5" not "4.4.5" Expect it around the time of CiviCon.
Try asking your question on the new CiviCRM help site.

routinet

  • I’m new here
  • *
  • Posts: 7
  • Karma: 0
  • CiviCRM version: Generally up-to-date
  • CMS version: Joomla
  • MySQL version: MySQL 5+
  • PHP version: PHP 5+
Re: Option Group customization
March 06, 2014, 07:34:01 am
RE: 4.4.5 vs 4.5, understood.  Thanks for the clarification.

Not so much that I didn't want that...more that I did not see a way to create the option groups in that screen, so began exploring other methods.  When I saw the is_optgroup flag in the db, I got all excited until it didn't work.  :)  After experimenting with the interface and the db a bit, I ran into the weirdness and stopped to find out more.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Option Group customization

This forum was archived on 2017-11-26.