0

I have a webform where the user also submits date. I would like to populate a date type field with the submitted date. I tried making variable by "Add variable", but I do not know how to access my webform submission.

0

Later I realised that I need to run a custom php code, so I wrote this, which actually works:

// use the submitted time value from the webform and convert it to time, also use it for an end date one year later
$time = strtotime($data['components']['submitted time']['value'][0]);
$time2 = strtotime('+1 year', $time);

//convert to date formats to the format used in these fields
$startdate = date('Y-m-d',$time);
$enddate = date('Y-m-d',$time2);

//update the field values and save the updates
$new_user_request -> field_start['und'][0]['value'] = $startdate;
$new_user_request -> field_end['und'][0]['value'] = $enddate;
user_save($new_user_request);

Hopefully this helps someone else too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.