Answers.Body: <p><a href="https://docs.civicrm.org/dev/en/latest/tools/debugging/#using-url-parameters" rel="nofollow noreferrer">Appending &amp;smartyDebug=1</a> to the URL will pop out a window that contains a lot of info including formName and formClass.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-24T14:16:16.753Z
Answers.Text: 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.
Answers.UserDisplayName: nonono1234
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-24T16:04:48.160Z
Answers.Text: Depends on what you're looking at. Something SearchKit-based would be quite different from Mailings, for example.
Answers.UserDisplayName: Lars SG
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-23T14:36:12.237Z
Answers.LastActivityDate: 2023-05-23T14:36:12.237Z
Answers.UserDisplayName: Lars SG
Answers.Body: <p>Yes, to modify the form you can hook_civicrm_buildForm. If you print the $formName you should be able to see formname on screen.</p>
  <p>I normally use Civi build in function for debuggings</p>
  <ol>
  <li>To print on screen - CRM_Core_Error::debug('$formname', $formName);</li>
  <li>To print in Civi logs - CRM_Core_Error::debug_va('$formname', $formName);</li>
  <li>Backtrace to show screen -  CRM_Core_Error::backtrace();</li>
  <li>Backtrace in log -  CRM_Core_Error::backtrace('show', TRUE);</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-23T12:33:28.513Z
Answers.Text: Thanks for your answer, should I run these debug codes inside the custom module directory?
Answers.UserDisplayName: nonono1234
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-23T14:21:36.127Z
Answers.Text: Yes, put exit; statement
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-23T08:42:04.433Z
Answers.LastActivityDate: 2023-05-23T08:42:04.433Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>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?</p>
  <p>I would greatly appreciate any assistance that anyone can provide. Thank you very much.</p>
  
Tags: <forms>
Title: How can I determine which PHP Form class a displaying Form belongs to?
ThreadText: # How can I determine which PHP Form class a displaying Form belongs to?
  
  (Asked by: username_0 on 2023-05-23)
  
  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.
  
  **Tags:** forms
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2023-05-23. Score: 1
  
  [Appending &smartyDebug=1](https://docs.civicrm.org/dev/en/latest/tools/debugging/#using-url-parameters) to the URL will pop out a window that contains a lot of info including formName and formClass.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_1**: Depends on what you're looking at. Something SearchKit-based would be quite different from Mailings, for example.  
  
  ---
  
  ### Answer by username_2 on 2023-05-23. Score: 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);
  
  > **Comments:**
  > **username_0**: Thanks for your answer, should I run these debug codes inside the custom module directory?  
  > **username_2**: Yes, put exit; statement  
  
  ---
  
  