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) »
  • Setting defaults
Pages: [1]

Author Topic: Setting defaults  (Read 661 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Setting defaults
July 11, 2011, 02:04:47 pm
I just got myself in a muddle using UFJoin api because it doesn't defaut to 'is_active' - which would seem to be intuitive. Not sure whether to set this default in the BAO or API but if the latter perhaps we should introduce functions like

_civicrm_api3_uf_join_create_defaults(){

}


or

_civicrm_api3_uf_join_defaults($action){

}

as a tidy place to put them?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Setting defaults
July 11, 2011, 11:29:38 pm
i'd vote for _civicrm_pai3_uf_join_create_defaults
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Setting defaults
July 11, 2011, 11:50:37 pm
And would you vote for the create function calling them where they exist or civicrm_api doing a

if (function_exists($defaultfnName) && empty($params['id'){
array_merge($defaultfnName(),$params);
}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Setting defaults
July 12, 2011, 12:03:07 am
Now let me see, my initial reaction would be in civicrm_api.
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Setting defaults
August 25, 2011, 01:29:54 am
OK

Implemented.

This will work across the API with the _ prefix & _defaults suffix

/*
 * Set defaults used for 'create' action
 * @return array $defaults array of default values
*/

function _civicrm_api3_address_create_defaults(){
  return array('is_primary' => 1);
}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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

This forum was archived on 2017-11-26.