[development] Modifying event date in hook_form

Gerhard Killesreiter gerhard at killesreiter.de
Wed Dec 5 09:57:09 UTC 2007

Hash: SHA1

Ron Parker schrieb:
> 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.

That's probably because event.module replaces your form stuff by its own
in event_form_alter. What you need to do is to implement your own
hook_form_alter and alter the stuff event put in, specifically th
default values. For this to work you need to make sure your module has a
higher weight in the system table than event.module.

Version: GnuPG v1.4.6 (GNU/Linux)


More information about the development mailing list