I have a form that users can fill out and it creates a node, an event node to be shown in the community calendar of my website. I'm using Rules to create the new node when the "Webform: After a webform has been submitted" event (requires Webform Rules module).
Everything is working well except for the Date field. The event node needs a date and time, that's kinda the point of a calendar!
I can select the webform data with [data:date-value]
and [data:time-value]
and I know that they output the correct data because if I put them into a regular text field ([entity-created:body:value]
) the date and time show up just fine. And I can use PHP if I need to:
<?php
echo $data['components']['date']['value'][0] ;
?>
I just don't know what Data Selector to choose for the date field. There's several that Rules knows about but so far I have no luck:
entity-created:field-date
- if I choose this, in the resulting page to set the new value, there is no PHP Evaluation or Replacement Patterns available to use, only the Data Selector ajax dropdown, which doesn't allow for the
[data:date-value]
. - and it says "
Data types: Select data of the type List<struct>.
"
- if I choose this, in the resulting page to set the new value, there is no PHP Evaluation or Replacement Patterns available to use, only the Data Selector ajax dropdown, which doesn't allow for the
entity-created:field-date:0
- it goes from 0 to 3 although there's only 1 date field for the event node, and they all the same- if I choose this, in the resulting page to set the new value, there is no PHP Evaluation or Replacement Patterns available to use, only the Data Selector ajax dropdown, which doesn't allow for the
[data:date-value]
. - and it says "
Data types: Select data of the type Struct.
"
- if I choose this, in the resulting page to set the new value, there is no PHP Evaluation or Replacement Patterns available to use, only the Data Selector ajax dropdown, which doesn't allow for the
entity-created:field-date:0:value (Start Date)
- in the resulting page to select the new value, it says: "Data types: Select data of the type Date." so I think it's a step in the right direction...
- now there's a plain value field I can use (direct input mode),
- instructions say: "The date in GMT. You may enter a fixed time (like 2016-06-04 16:01:07) or any other values in GMT known by the PHP strtotime() (link is external) function (like "+1 day"). Relative dates like "+1 day" or "now" relate to the evaluation time." If I put "+1 day" into the field and test it by submitting the webform, then a node is correctly created with the date field set one day into the future.
- I can switch to the Data Selection mode and I have Data Selectors, PHP Evaluation and I can add an offset.
- if I set the new value to
[data:date-value]
or[data:date-value] [data:time-value]
then it doesn't say there's any errors, but when I test it but submitting the form and checking the new node that was created, the Date field was not set - if I try to set the value to
<?php echo $data['components']['date']; ?>
... still no luck. And no errors are displayed or logged.
- if I set the new value to
- it also lists
entity-created:field-date:0:value2 (End Date)
andentity-created:field-date:0:duration (Duration)
as possible "Set a data value" things to select
Anybody have any idea what I'm supposed to do here?? Thank you!
return $value + strtotime($data['components']['date']['value'][0]);
into the PHP Evaluation field with site:current-date still in the Data Selector field, it does set the Date field of the new node BUT IT DOESN'T SET THE DATE/TIME INTO THE FUTURE as expected! THEREFOR I CAN CONCLUDE that the PHP Evaluation field CANNOT access the $data variable and probably nothing but the $value variable D: