1

I would like to add a settings form to a new extension to hold some extension-specific settings.

I've put together the extension and form using civix, and am testing in civiCRM 4.7.17 on local MAMP.

After reading the docs here and here, i've tried to copy the setup for settings in this repo (metadata form example from docs), and also looking at this repo.

I've looked at this question, but the issue i'm having is getting the settings array returned from settings/'myextension'.settings.php to actually populate anywhere in the first place.

For example when installing/enabling the extension, hook_alterSettingsFolders fires with the same code as in the above repos, but if I try to find my settings with the apiv3 call like this form (the one I used as well) does, the settings group has not been added, and so my form only populates with submit buttons and a var_dump of $_settings is empty.

I'm not seeing anything obvious in the civicrm or php logs.

Is there some key step i'm missing to get civicrm to recognize these settings?

Thanks!

1 Answer 1

1

Perhaps another example will help you along:

The Form: https://github.com/jake-mw/CDNTaxReceipts/blob/master/CRM/Cdntaxreceipts/Form/Settings.php

And some of the settings are retrieved here: https://github.com/jake-mw/CDNTaxReceipts/blob/master/cdntaxreceipts.functions.inc#L73

4
  • Thanks for the example! I took this route and got it working no problem... It uses a pretty different strategy than the other examples that use an extension.settings.php and the API. Is there any reason you know of that one might be preferred over the other? Apr 2, 2017 at 22:36
  • Glad that helped you! We wrote that yeara ago - I still use it as my own goto example; I honestly don't know about any other ways to do it Apr 3, 2017 at 0:50
  • Usually the API is preferred because the BAO functions might show different behaviour. But it is no law and it makes sense to at least start with what makes sense to you and move on to other steps once you are comfortable with what you are doing :-) Apr 3, 2017 at 15:32
  • Thanks @ErikH-CiviCooP - my next settings page will use the API 😀 Apr 3, 2017 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.