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) »
  • Trying to capture form fields from Profile inside of hook
Pages: [1]

Author Topic: Trying to capture form fields from Profile inside of hook  (Read 865 times)

cjungheim

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
Trying to capture form fields from Profile inside of hook
August 09, 2010, 08:09:22 am
I'm implementing civi_relate_civicrm_postProcess and trying to capture some Custom data fields in order to pass them along to civicrm_contact_add API, but although I can at least get an array of the _elements:
    foreach ( $form->getVar('_elements') as $key => $value ) {
      print_r($value);
        }
but I'm trying to get a custom field called Parent/Guardian firstname further down in _elements array 
...
[_values] => Array (
  • => 1012 ) [_label] => State (Primary) [_type] => select [_flagFrozen] => [_persistantFreeze] => 1 [_attributes] => Array ( [name] => state_province-Primary ) [_tabOffset] => 0 [_tab] => [_lineEnd] => [_comment] => ) [10] => HTML_QuickForm_text Object ( [_label] => Postal Code (Primary) [_type] => text [_flagFrozen] => [_persistantFreeze] => 1 [_attributes] => Array ( [maxlength] => 12 [size] => 12 [name] => postal_code-Primary [type] => text [value] => 60035 ) [_tabOffset] => 0 [_tab] => [_lineEnd] => [_comment] => ) [11] => HTML_QuickForm_text Object ( [_label] => Parent/Guardian First Name [_type] => text [_flagFrozen] => [_persistantFreeze] => 1 [_attributes] => Array ( [name] => custom_12 [type] => text [value] => Betty )

 ...
but I can't come up with a way to capture specifically [name] => custom_12 [type] => text [value] => Betty ) into a variable.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Trying to capture form fields from Profile inside of hook
August 09, 2010, 09:04:56 am

any specific reason you are not doing something similar to:

Code: [Select]
        $params = $form->controller->exportValues( $form->getVar( '_name' ) );

that should give you the values of all POST'ed variables

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

cjungheim

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
Re: Trying to capture form fields from Profile inside of hook
August 09, 2010, 10:32:02 am
no specific reason not to have done exactly as suggested, short of lacking the good sense at the late night last night to have done what I believe would have been a well advised reading of the fine manual at:
http://pear.php.net/manual/en/package.html.html-quickform-controller.php

This code by way of example is looking to allow me now to get exactly the variables I need:
       $params = $form->controller->exportValues( $form->getVar( '_name' ) );
       $parent_first_name = CRM_Utils_Array::value( 'custom_12', $params );
       print("$parent_first_name");
       $parent_last_name = CRM_Utils_Array::value( 'custom_13', $params );
       print("$parent_last_name");

a million thanks and a thousand more!
cj

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Trying to capture form fields from Profile inside of hook

This forum was archived on 2017-11-26.