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) »
  • documentation error for hook_civicrm_validate
Pages: [1]

Author Topic: documentation error for hook_civicrm_validate  (Read 474 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
documentation error for hook_civicrm_validate
April 01, 2012, 04:05:26 am
Documentation page: http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmvalidate

documentation advises the hook implementation should return 'true if form validates successfully' but this causes the following warning to be issued ...

Quote
Warning: array_merge(): Argument #2 is not an array in CRM_Utils_Hook->runHooks() (line 125 of .../sites/all/modules/civicrm/CRM/Utils/Hook.php).

The code that gives the warning is ...

Code: [Select]
                if ( !empty( $fResult ) ) {
                    $result = array_merge( $result, $fResult );
                }

If $fResult is 'true' PHP doesn't consider it empty, and array_merge throws the warning.

Proposal: Change the documentation to say the function returns 'an array with input field names as keys and error message strings as values. The empty array indicates no validation errors'. The return statement in the examples should simply be 'return $errors;'

I'm happy to update the documentation, but wanted to socialise this first.

Ken

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • documentation error for hook_civicrm_validate

This forum was archived on 2017-11-26.