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) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Pre-populated data in Civievent forms?
Pages: [1]

Author Topic: Pre-populated data in Civievent forms?  (Read 1486 times)

obrienmd

  • Guest
Pre-populated data in Civievent forms?
November 18, 2008, 09:52:39 am
I'd like to provide my client with pre-populated data in their civievent event management forms.  For instance, when they create a new event, I'd like the forms to already have basic text information that they can modify, like:

Event Summary:
-----------------
[Speaker] will present on [subject], from
[his/her] experience at [previous employer].
-----------------

Any thoughts?  Am I missing an easy way to do this?

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: Pre-populated data in Civievent forms?
November 18, 2008, 10:20:19 am

You can implement the buildForm hook for that form (CRM_Event_Form_ManageEvent_EventInfo.php). The QuickForm function setDefaults should do the trick. So something like

Code: [Select]
function myModule_civicrm_buildForm( &$formName, &$form ) {
   if ( $formName == 'CRM_Event_Form_ManageEvent_EventInfo' ) {
      $defaults = array( 'summary', "[Speaker] will present on [subject], from\n[his/her] experience at [previous employer].");
      $form->setDefaults( $defaults );
   }
}

you'll need to test/tweak and handle other conditions (probably skip it if editing an event page etc)

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

obrienmd

  • Guest
Re: Pre-populated data in Civievent forms?
November 18, 2008, 11:19:32 am
I'm not much of a coder, but that sounds easy.  One question:  Any advice as to how to code that "skip" if editing?

Thanks!

obrienmd

  • Guest
Re: Pre-populated data in Civievent forms?
November 18, 2008, 11:46:49 am
Oy!  I overestimated myself.  Could you possibly be so gracious as to expand upon the "buildForm hook" and "QuickForm function" mojo for me?

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: Pre-populated data in Civievent forms?
November 18, 2008, 12:37:56 pm

1. you need to build and enable a drupal module

2. you need to understand drupal hooks a wee bit. and implement these hook in your drupal module

if the above language seems complex, you might want to consult with your local drupal/php guru. We ship a simple drupal module under drupal/civitest.module.sample (you'll need to rename it and also create a info file)

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Pre-populated data in Civievent forms?

This forum was archived on 2017-11-26.