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) »
  • hook in custom fields
Pages: [1]

Author Topic: hook in custom fields  (Read 282 times)

henro

  • I post occasionally
  • **
  • Posts: 115
  • Karma: -1
  • CiviCRM version: 4.5.0
  • CMS version: drupal
  • MySQL version: 4.2.7.1
  • PHP version: 5.2.0
hook in custom fields
December 19, 2014, 12:04:16 am
hi all,

how can i set / implementations a hook for custom field

i have a custom field which id 11, this is a little for my code. i see error caused the variable $custom_fields ,

will anyone , what must to i do to solved this one, i have readed http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmvalidate

but for me it look like hard to understanding

function mymodule_civicrm_validate( $formName, &$fields, &$files, &$form ) {
    // sample implementation
    $errors = array( );
    if ( $formName == 'CRM_Contact_Form_Contact' ) {
       // ensure that external identifier is present and valid
       $custom_fields = CRM_Utils_Array::value( 'custom_11_-1'$custom_fields );
       if ( ! $externalID ) {
          $errors['custom_11_-1'] = ts( 'External Identifier is a required field' );
       } else if ( ! myCustomValidatorFunction( $externalID ) ) {
          $errors['custom_11_-1'] = ts( 'External Identifier is not valid' );
       }
    }
    return empty( $errors ) ? true : $errors;
 
}


thanks for help

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: hook in custom fields
December 19, 2014, 02:10:49 am
Code: [Select]
$custom_fields = CRM_Utils_Array::value( 'custom_11_-1', $custom_fields );You forgot the comma separating the two parameters?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook in custom fields

This forum was archived on 2017-11-26.