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 (Moderator: Donald Lobo) »
  • Dynamic Options for Custom Data "Select" Field
Pages: [1]

Author Topic: Dynamic Options for Custom Data "Select" Field  (Read 1246 times)

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Dynamic Options for Custom Data "Select" Field
July 08, 2009, 11:55:42 am
Drupal's CCK provides a PHP code format to specify the "allowed values" list of a field using the 'select' widget. I have a site with a need for the same feature in CiviCRM.

The specific issue is that this site needs to limit access to events by group membership, meaning that each event needs to be labeled as being accessible and not accessible to certain group(s).

In our prototype implementation, the approach we are taking is to add custom select fields to CiviEvents, into which we manually the list of groups and their IDs. Custom code then examines those lists and examines the current user and then determines his eligibility to view or register for this event. This works, but obviously requires manual maintenance of these select options.

The ideal would be a system like CCK's, wherein a few lines of PHP code could generate the option list. Barring that, I think that we could also just leave the lists essentially empty, and then use a bit of jQuery to build the list of options--custom module code would provide the list of options to the jQuery code. This approach I think is simple and will work--as far as I can see, the values for such custom fields are stored as actual values in the DB, as opposed to pointers to a record in another table.

But I wanted to ask what people think about both ideas, i.e.:

 1. PHP code like CCK
 2. jQuery to build the list

I am asking the merits of these ideas, and the feasibility of implementing #1, and if anyone else has interest in such a feature.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

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: Dynamic Options for Custom Data "Select" Field
July 08, 2009, 12:01:45 pm

check:

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmcustomFieldOptions

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

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Dynamic Options for Custom Data "Select" Field
July 08, 2009, 12:06:50 pm
How do you like that? I just today reviewed the hooks page, looking into how to retrieve a custom field value for a given entity (didn't find a way BTW) and I saw that hook and glossed over it. NOW I want it for this. :)

Thanks.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Dynamic Options for Custom Data "Select" Field

This forum was archived on 2017-11-26.