I have a content type "order" that when created also creates a content type "job". I have this working well except for this: The order content type has a "date_required" field (datetime) and the "job" content type has a "date_scheduled" field(datetime). I need to subtract 14 days from the date_required field and populate the date_scheduled field. I've had no problem moving the actual date from "order" to "job":

return array(
 0 => array('value' =>  '[node:field_order_date-datetime]');
);

I am having trouble using php functions (strtotime) inside the PHP advanced code field. I'm a designer so my php skills are lame. Any help would be greatly appreciated.

BTW, this module is sweet!

Comments

selwynpolit’s picture

Component: Rules Core » Rules Engine

I am trying to do something similar. I want to write the current date into a date field. I am able to write other values into other fields. I found lots of references to it in issue queue but can't seem to make it work.

I put the following into Advanced: Specify the fields value with PHP code

Here are some of the variations I have tried. Can anyone shed some light in this?

//$mytime = date('Y-m-d G:i') ; 
//$mytime = time();
$mytime = date(c);
$myarray= array(0 => array('value' => $mytime),);
//$myarray = array('value' => $mytime);
dsm($myarray) ;
return $myarray ;
dogboy72’s picture

selwynpolit’s picture

Thanks for that. I think I could do it in a module but I really wanted to do it from within rules. Not sure if there is something really obvious that I am missing. The instructions on screen in rules show a simple example which I tried but I can't seem to make it work at all. I have spent way too many hours on this of course.

selwynpolit’s picture

I tried writing a text value from the advanced code field into a text field and I don't seem to be able to do that either. I tried all kinds of variations but it didn't seem to work. Has anyone tried this? Seems like it should be pretty simple, right?

If I have a field called field_my_text:

$myarray= array(0 => array('value' => 'mytext here',);
return $myarray ;

ok, it seems like you don't need the <?php?> tags

Appreciate any suggestions.

TR’s picture

Component: Rules Engine » Rules Core
Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is no longer supported, and things work differently in Rules for D7 and D8.