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) »
  • buildForm Hook working for Contribution not for Event?
Pages: [1]

Author Topic: buildForm Hook working for Contribution not for Event?  (Read 2106 times)

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
buildForm Hook working for Contribution not for Event?
December 29, 2009, 06:10:18 pm
I was able to do a hook to define default values for a contribution form but I would like to add the same hook to event forms.

The contribution still works but the sign up form for the event is not. I am trying to do the hook for all events (>=1) with the $formName  'CRM_Event_Form_Registration_Register'.

This is what I have:

Code: [Select]
function joomla_civicrm_buildForm( $formName, &$form ) {
   if (($formName == 'CRM_Contribute_Form_Contribution_Main'
&& $form->getVar('_id') == 2) ||
($formName == 'CRM_Event_Form_Registration_Register'
&& $form->getVar('_id') >= 1)){       
        $defaults['country-Primary'] = 1228;
$defaults['state_province-Primary'] = 1004;
$defaults['group[11]'] = 1;
$defaults['group[8]'] = 1;
$defaults['group[10]'] = 1;
        $form->setDefaults( $defaults );
    }
}

I tried it with the event conditional alone but it doesn't work... only the contribution seems to be working fine.

Thanks for any help or pointers.... Andres
Andres

Open Source is Green

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: buildForm Hook working for Contribution not for Event?
December 29, 2009, 09:44:46 pm
Code: [Select]
($formName == 'CRM_Event_Form_Registration_Register' && $form->getVar('_id') >= 1)you might want to change this half if condition with

Code: [Select]
($formName == 'CRM_Event_Form_Registration_Register' && $form->getVar('_eventId') >= 1)
hope this help

kiran
You Are Designed To Choose... Defined By Choice.

aspagarino

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 10
  • San Diego Joomla
    • California Center for Sustainable Energy
  • CiviCRM version: CiviCRM 4.3
  • CMS version: Drupal 7
Re: buildForm Hook working for Contribution not for Event?
December 30, 2009, 09:15:18 am
Thanks... just gave you some good Karma for 2010 and I just donated a little contribution for CiviCRM ;D
Andres

Open Source is Green

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • buildForm Hook working for Contribution not for Event?

This forum was archived on 2017-11-26.