[development] Modifying event date in hook_form

Ron Parker sysop at scbbs.com
Wed Dec 5 08:19:03 UTC 2007

I've posted this in Forums, but doesn't look like I'm going to get a 
response, and I'm pretty sure someone here knows this right off the bat. 

I'm creating an agenda module for 5.x. So far, it only requires the 
event module.  The module creates a new content type: "agenda".  It is 
set to appear in all calendars (for now) so has event start and end date 
fields associated with it.

<>To use it, I create an event node, then the module allows me to create 
an agenda node that corresponds to the event node. The agenda content 
type has start/end date fields. I do not have jscalendar.module 
installed.  I wish to pass the start and end dates of the corresponding 
event node to the agenda node automatically.

I'm currently trying to use the following code in hook_form, which I 
modified from the event_form_alter() function:

  $event = node_load($node->event_id); // Load corresponding event node

    if (arg(1) == 'add' || arg(1) == 'ognodeadd') {
      $form['event_start'] = array(
        '#type' => 'fieldset',
        '#title' => t('Start date'),
        '#weight' => -15
      $form['event_start']['date'] = 
event_form_date($event->event_start, 'start', $event->start_offset);

But, nothing is coming through. I still get the default time when 
creating a new agenda node, and not the time from the corresponding 
event node.  I know the hook itself (agenda_form) is working because 
other code does work:

  if (arg(1) == 'add' || arg(1) == 'ognodeadd') {
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => true,
      '#default_value' => theme('agenda_default_title', $event),
      '#weight' => -5
  } else {
    $form['title'] = array(
      '#type' => 'textfield',
      '#title' => t('Title'),
      '#required' => true,
      '#default_value' => $node->title,
      '#weight' => -5

I have tried other ways of doing it suggested here:



But, nothing seems to be working for me.  Can someone please help me 
with this?


Ron Parker
Software Creations               http://www.scbbs.com
Self-Administration Web Site     http://saw.scbbs.com
SDSS Subscription Mgmt Service   http://sdss.scbbs.com
Central Ave Dance Ensemble       http://www.centralavedance.com
R & B Salsa                      http://www.randbsalsa.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20071205/0e8362c1/attachment-0001.htm 

More information about the development mailing list