Note that there are some explanatory texts on larger screens.

plurals
  1. PODrupal hook to change date CCK field value
    primarykey
    data
    text
    <p>I need to send out a reminder email the DAY BEFORE a Calendar Event as well as the DAY AFTER. Unfortunately, I can't use Rules Scheduler, because the Tokens can't be manipulated with PHP. It doesn't work if I have </p> <pre><code>[node:field_event_date-datetime] -1 day </code></pre> <p>as the scheduled time.</p> <p>What I've ended up doing is creating two "dummy" date fields for DAY BEFORE and DAY AFTER, and I'm trying to hook into the form, grabbing the event date, using some PHP like strtotime() to add/subtract a day, and make these the values that would go into the database. </p> <p>I've tried linking to the #submit part of the form, but in phpMyAdmin, all values are NULL. For this code i haven't even changed the date, I'm just trying to get values to appear in the database.</p> <pre><code>function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) { if ($form_id == "event_node_form") { $form['#submit'][] = '_mymodule_after_build'; // Makes the fields invisible $form["field_event_day_before"]["#access"] = FALSE; $form["field_event_day_after"]["#access"] = FALSE; } } function _mymodule_after_build($form, &amp;$form_state) { $eventcopy = array(); // copy the value part from the Event $eventcopy = $form['field_event_date'][0]['#value']; // without doing any PHP yet, simply copy the values. Doesn't show up in db. $form['field_event_day_before'][0]['#value'] = $eventcopy; dsm($form); return $form; } </code></pre> <p>I've read the tutorials about using <a href="http://drupal.org/node/520012" rel="nofollow">Rules Scheduler with CCK</a> and</p> <p>I'm also following <a href="http://drupal.org/node/1118580#comment-4458102" rel="nofollow">Schedule email to go out based on CCK date field - not working for me</a></p> <p>Am I using the right hooks? How do I intercept the inputted date value properly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload