if ($formName == 'CRM_Contribute_Form_Contribution_Confirm' && $form->_id == 1) {

   CRM_Core_Resources::singleton()->addScriptFile(drupal_get_path('module','custom_water') .'/',


When I use the above code as mentioned in the link https://wiki.civicrm.org/confluence/display/CRMDOC43/Resource+Reference#ResourceReference-Introduction

Add a Javascript file PHP CRM_Core_Resources::singleton()->addScriptFile('com.example.foo', 'bar.js');

I get an error : Fatal error: Class 'CRM_Core_Resources' not found in

I am using drupal 7 with CiviCRM

  • I think the error message you're posting got cut off, please finish it? Also, are you adding this code to a Drupal module or CiviCRM extension? – Jon G - Megaphone Tech Mar 20 '16 at 16:58
  • @JonG I am adding the code in drupal module – harshal Mar 21 '16 at 7:26

if it is on drupal module add civicrm_initialize(); method above that line

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.