0

If I want to modify a form, should I use hook_civicrm_buildForm? This function requires a formName argument, so how can I identify the FormName or Form ID of the form I'm currently viewing on the site? Does CiviCRM have built-in debugging tools for this purpose, or do I need to use a third-party extension like Devel for Drupal?

I would greatly appreciate any assistance that anyone can provide. Thank you very much.

2 Answers 2

1

Yes, to modify the form you can hook_civicrm_buildForm. If you print the $formName you should be able to see formname on screen.

I normally use Civi build in function for debuggings

  1. To print on screen - CRM_Core_Error::debug('$formname', $formName);
  2. To print in Civi logs - CRM_Core_Error::debug_va('$formname', $formName);
  3. Backtrace to show screen - CRM_Core_Error::backtrace();
  4. Backtrace in log - CRM_Core_Error::backtrace('show', TRUE);
2
  • Thanks for your answer, should I run these debug codes inside the custom module directory?
    – nonono1234
    Commented May 23, 2023 at 12:33
  • Yes, put exit; statement Commented May 23, 2023 at 14:21
1

Appending &smartyDebug=1 to the URL will pop out a window that contains a lot of info including formName and formClass.

2
  • Thank you for your response. I would like to know how to use the solution provided if the form is an AJAX form. I tried adding '&smartyDebug=1', but it only shows the information before the form is loaded and appears.
    – nonono1234
    Commented May 24, 2023 at 14:16
  • Depends on what you're looking at. Something SearchKit-based would be quite different from Mailings, for example.
    – Lars SG
    Commented May 24, 2023 at 16:04

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.