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) »
  • Documentation of fields
Pages: [1]

Author Topic: Documentation of fields  (Read 767 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Documentation of fields
March 18, 2011, 01:11:04 am
Hi,

Following Eileen's comment (and moving to the forum)

http://civicrm.org/blogs/erikhommel/location-api-obsolete-v3-api-use-address-email-phone-and-website-api#comment-5607

Yes, getfields is the action to get fields (duh) and is the place to add the extra fields (re duh, shame I missed it).

The "problem" is that we will have different fields based on the action (you can use type_name for the create, but not for the get)

I'd suggest to add a param "action" to getfields.  by default, it returns all the fields that might be used for one action or the other, but you can filter to get only those for one action.

eg.

Code: [Select]
function civicrm_api3_address_getfields ($params) {
initialize
try {
            $dao = civicrm_api3_get_DAO ('address');
            $file = str_replace ('_','/',$dao).".php";
            require_once ($file);
            $d = new $dao();
            $fields= $d->fields();

if (!array_key_exists ('action') || params['action'] == 'create' ||  params['action'] == 'modify') {
  $fields [] = "address_type_name"
}

civicrm_create_success ($fields,$params,$dao);
}

}catch
}
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Documentation of fields
March 21, 2011, 02:01:22 am
That would be a nice addition. I would be tempted though to see what feedback we get on the getFields once people start using it?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

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

This forum was archived on 2017-11-26.