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 (Moderator: Donald Lobo) »
  • Date Issue in upgrade from 3.0 to 3.3
Pages: [1]

Author Topic: Date Issue in upgrade from 3.0 to 3.3  (Read 560 times)

mhenning

  • Guest
Date Issue in upgrade from 3.0 to 3.3
January 12, 2011, 10:38:12 am
I had code working in 3.0 to inject 2 civicrm date fields into the Drupal new user form.  Now that I upgraded to 3.3 it no longer works.

The code looked like:

function nasi_core_civicrm_buildForm($formName, &$form) {
   //new member/assoc member signup form
   if($_SERVER['SCRIPT_URL']=='/admin/user/user/create'){

      $form->add('date',
             'join_date',
             'Join Date',
             CRM_Core_SelectValues::date( 'relative')
           );
      $form->add('date',
             'end_date',
             'End Date',
             CRM_Core_SelectValues::date( 'relative')
           );

      $defaults['join_date']['M']= 11;
      $defaults['join_date']['d']= 1;
      $defaults['join_date']['Y'] = date("Y",mktime())-1;

      $defaults['end_date']['M']= 10;
      $defaults['end_date']['d']= 31;
      $defaults['end_date']['Y'] = date("Y",mktime());
      $form->setDefaults($defaults);
         
      // Also assign to template
      $template =& CRM_Core_Smarty::singleton( );
      $beginHookFormElements = $template->get_template_vars('beginHookFormElements');
      if (!$beginHookFormElements) { $beginHookFormElements = array( ); }
      $beginHookFormElements[] = 'join_date';
      $beginHookFormElements[] = 'end_date';
      $form->assign('beginHookFormElements', $beginHookFormElements);
   }
}

I have found that the new way to add date fields is:
      $form->addDate(
             'end_date',
             'End Date',
             false,
             array('formatType' => 'relative')
           );

But, I do not know how to set the defaults or to get the javascript calendar to show up.  Anyone know what I must do to get this to work? 

Thanks,
Matt



mhenning

  • Guest
Re: Date Issue in upgrade from 3.0 to 3.3
January 12, 2011, 04:51:15 pm
I couldn't figure this out so I ended up going with textfields instead

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Date Issue in upgrade from 3.0 to 3.3

This forum was archived on 2017-11-26.