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) »
  • Using hook_civicrm_buildform, trying to add extra info to "confirmation" page
Pages: [1]

Author Topic: Using hook_civicrm_buildform, trying to add extra info to "confirmation" page  (Read 415 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Using hook_civicrm_buildform, trying to add extra info to "confirmation" page
February 04, 2014, 06:55:02 pm
I am using the hook_civicrm_buildform to try to add some extra information to a contribution page confirmation.   I am following the example at the bottom of the page at: http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_buildForm

The code in my tpl file is:  <div id="testfield-tr">
 
Code: [Select]
<div>My new field:</div>
 
  <div>{$form.testfield.html}</div>
 
 
</div>

{* reposition the above block above #someOtherBlock *}
<script type="text/javascript">
  cj('#testfield-tr').insertAfter('#help')
</script>

 The HTML is successfully part of the contribution "confirm" page, BUT the output for $form.testfield.html is always empty.

In my hook, I am setting up the element as follows:

Code: [Select]
$tmp = $form->add('text', 'testfield', ts('Recipient Names:'),
                     $names_arr,
                     false);

I have also tried
Code: [Select]
$tmp = $form->add('select', 'testfield', ts('Recipient Names:'),
                     $names_arr,
                     false);

but neither one produces any extra text. (The only thing that gets displayed from my tpl file is <div>My new field:</div>


FYI: I don't really need a "input" field. I really just want to add some extra text

My hook only has an impact if ( $formName == 'CRM_Contribute_Form_Contribution_Confirm')
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

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: Using hook_civicrm_buildform, trying to add extra info to "confirmation" page
February 04, 2014, 11:31:28 pm
You will need to set the default value for the field like this:
Code: [Select]
$defaults = array('testfield' => 12345);
$form->setDefaults( $defaults );

Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Using hook_civicrm_buildform, trying to add extra info to "confirmation" page
February 07, 2014, 09:16:25 am
Thanks! That worked for me.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Using hook_civicrm_buildform, trying to add extra info to "confirmation" page

This forum was archived on 2017-11-26.