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) »
  • how to validate contact form by custom field
Pages: [1]

Author Topic: how to validate contact form by custom field  (Read 382 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
how to validate contact form by custom field
December 03, 2014, 08:33:02 pm
hi all,
i want to validate contact form, where the field i want to validate is by custom field,

i have readed this
http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_validateForm

its very help,
but the example field validated there is by " addres " field and as i know it is not a custom field .

this the warning i face

 
    Notice: Undefined index: custom_9 in myextension_civicrm_validateForm() (line 119 of C:\xampp\htdocs\drupal\extentions\com.example.myextension\myextension.php).
    Warning: Invalid argument supplied for foreach() in myextension_civicrm_validateForm() (line 119 of C:\xampp\htdocs\drupal\extentions\com.example.myextension\myextension.php).




could anyone give to me an example to validate form conctac by custom field

thanks in advance

DaveFF

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 5
  • Developer at Future First
    • Future First
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.34
  • MySQL version: 5.5
  • PHP version: 5.3
Re: how to validate contact form by custom field
December 04, 2014, 01:04:01 am
Looking at what happens on my test system, when custom fields are coming back in $fields they have another number after them (eg. I'm getting custom_150_21, custom_151_21, custom_152_21). This didn't appear to be the entity ID (22 in my test case) or the custom group ID (19 in my test case).

I'd suggest temporarily putting a debugging watchdog statement:
Code: [Select]
watchdog('yourextension', print_r($fields, TRUE), array(), WATCHDOG_DEBUG);in your hook function so you can see what is coming back in $fields.

Edit: I think that extra number is the id of the row in the particular custom group table where that custom data lives.
« Last Edit: December 04, 2014, 01:24:18 am by DaveFF »
Do Not Contact Until extension: https://civicrm.org/extensions/do-not-contact-until
Organisation Name De-duplicator extension: https://civicrm.org/extensions/organisation-name-de-duplicator

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
Re: how to validate contact form by custom field
December 04, 2014, 02:16:35 am

Thank a lot DaveFiFcode very useful,
i change TRUE be False , and the all of that field name appear in the form

eventhough i cannot solve validation by custom field but i think i have solved my issue by main field in contact form.

thanks again :)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • how to validate contact form by custom field

This forum was archived on 2017-11-26.