I've been at this for days, but I finally think I maybe kinda sorta found part of the problem, maybe...but I don't know how to fix it.

I'm working on a Drupal site with the CiviCRM module running. I have a form on which I'd like to alter the data before saving it to the database. As a result, I've been struggling with getting ANY of the available CiviCRM hooks to fire.

I installed the "civicrm_developer" module, which is sort of a complement to Devel, in that it is used to help see into objects and other variables. Looking in the module's .module file, you see all of the CiviCRM hook functions, which are being used in the module to dpm() whatever variables were passed to them. For example...

function civicrm_developer_civicrm_buildForm($formName, &$form){
    drupal_set_message("hook_civicrm_buildForm called: formName is $formName");

Thats it. There are no includes or anything else, just hooks and printing variables, for each and every hook available in CiviCRM. The civicrm_developer module indeed works as intended. On the specific page I'm working with, there is a CiviCRM form and the civicrm_developer module prints a populated Krumo above that form, as would be expected when dpm()'ing a variable in Drupal.

However, attempts at making a custom module which uses one or two of those same hooks, can never seem to get to that same data. I've gone far as copying the civicrm_developer module (just one .module and .info file) to my custom module and changed the hook nomenclature from "civicrm_developer" to, let's say, "mymodule".

So, my module, which is practically an exact copy of the civicrm_developer module with the exception of the hook name, will not generate a Krumo above the form as the civicrm_developer module did when it was enabled. And yes, I've made sure that my module was enabled.

For example, this is the same function from earlier as written in my custom module...

 function mymodule_civicrm_buildForm($formName, &$form){
    drupal_set_message("mymodule_buildForm called: formName is $formName");

It might also be worth mentioning that the "mymodule" name in use is unique to that module, i.e. does not match the theme name or anything else that would cause a name collision...at least that I know of.

I can't figure out why the same hooks work in one module but not the other. It just doesn't make any sense.


there is no hook called hook_buildForm in drupal, acctually the hook you are trying to implement is hook_civicrm_buildForm, so to get it work you should use mymodule_civicrm_buildForm, you always can use hook_form_alter or more specifically hook_form_FORM_ID_alter to make change on any form in drupal

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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