CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • What to do if hook_civicrm_validate() gets called multiple times
Pages: [1]

Author Topic: What to do if hook_civicrm_validate() gets called multiple times  (Read 756 times)

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
What to do if hook_civicrm_validate() gets called multiple times
July 15, 2010, 08:50:39 pm
I'm using 4 distinct profiles for the Drupal registration page, and have implemented hook_civicrm_validate() so I can do a bit of custom validation on the fields.

The hook gets called, but it gets called 3 times.  At first, I thought it was getting called for each profile group, but AFAICT, the $form object is either exactly the same (as is the field list), and as a result, I'm not sure what I'm supposed to do in each of the three invocations.

Each time:
  • The form name is CRM_Profile_Form_Dynamic
  • The $fields param looks exactly the same to me
  • I can't see any difference in the $form object either

I'm assuming that it doesn't cause any harm if it gets called 3 times, but that I should only run my validation once.  But who knows?

This is running against 3.1.4 right now.

I'm guessing that if I return errors, I'll end up returning the errors 3 times, which is going to look kind of silly.

Is there any real difference between the 3 invocations?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • What to do if hook_civicrm_validate() gets called multiple times

This forum was archived on 2017-11-26.