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) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Looking for a hook to create & populate custom data field.
Pages: [1]

Author Topic: Looking for a hook to create & populate custom data field.  (Read 1340 times)

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Looking for a hook to create & populate custom data field.
November 07, 2012, 06:04:57 pm
I hope this is possible...

I'm working on my tax field extension and in our earlier rendition we created a custom field that held the rate of tax that we wanted to apply. Then we referenced the value of the field whenever we needed to apply tax to a membership or an event registration.

What I'd like to do with my extension is create a custom field for tax when the module is activated and then provide a configuration page where the administrator can apply a number for the rate of sales tax that is going to be calculated.

I see that hooks are available to populate custom fields with data (http://book.civicrm.org/developer/current/techniques/hooks/) but what about a hook to create the field?

If this is going to be particularly difficult or for some reason can't be done, I'm open to looking at other methods to store the tax rate. In fact it may be a better idea to create a db table so we can have a whole series of taxes that can be applied per jurisdiction. My plan is to create a simpleTax module for applying a tax or taxes and then expanding on it so that it can provide solutions for a number of scenarios.

Anyway, I appreciate any tips or feedback. I'm using the great civix tool and can't say enough good things about it  ;D

Thanks,
Andrew
My CiviCRM Extension Workshop: https://github.com/awasson

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: Looking for a hook to create & populate custom data field.
November 07, 2012, 08:13:02 pm

check how civiengage does it:

http://svn.civicrm.org/civicrm/trunk/drupal/modules/civicrm_engage/civicrm_engage.install

that is a drupal module, but you can use very similar code in an extension

the xml format allows you to create new custom groups and add custom fields etc. However it is not documented :(

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

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: Looking for a hook to create & populate custom data field.
November 07, 2012, 10:43:00 pm
Thanks lobo,

I'll give that a try.

Andrew
My CiviCRM Extension Workshop: https://github.com/awasson

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Looking for a hook to create & populate custom data field.

This forum was archived on 2017-11-26.