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 get profile_id & contact_id in validateForm hook for profiles?
Pages: [1]

Author Topic: How to get profile_id & contact_id in validateForm hook for profiles?  (Read 666 times)

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
How to get profile_id & contact_id in validateForm hook for profiles?
July 01, 2013, 10:27:05 am
Hi,

I want to validate an specific Profile Edit Form.
I cannot get from $form object sent to the validateForm method, the profile_id nor the contact_id.

Printing $form, I get

Code: [Select]
CRM_Profile_Form_Edit Object
(
    [_postURL:protected] => /civicrm/profile/view?reset=1&id=7&gid=13
    [_cancelURL:protected] => /civicrm/contact/search/custom?csid=16&force=1&crmSID=3_d
    . . .
    [_id:protected] => 7
    [_gid:protected] => 13
     . . .

_id and _gid are protected, so doing in the hook $form->_id or $form->_gid doesn't work
I need them to validate the proper Profile and check the proper Contact.

any ideas?

cheers!


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: How to get profile_id & contact_id in validateForm hook for profiles?
July 01, 2013, 11:36:26 pm
You need to retrieve them like this:
Code: [Select]
$profileId = $form->getVar( '_gid');Not sure where the contact_id is in the specific form you are using, I assume it would be in the _values (that you pick up with $form->getVar too). Or do you want the contact_id of the logged in user?
« Last Edit: July 01, 2013, 11:38:10 pm by Erik Hommel »
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Re: How to get profile_id & contact_id in validateForm hook for profiles?
July 02, 2013, 02:40:21 am
yes, of course.. getVar() did the trick

Tx Erik !!!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • How to get profile_id & contact_id in validateForm hook for profiles?

This forum was archived on 2017-11-26.