Closed (fixed)
Project:
Webform
Version:
7.x-4.0-beta3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
3 May 2014 at 04:38 UTC
Updated:
13 Aug 2014 at 05:50 UTC
Jump to comment: Most recent
I am at my wits end trying to use the hook_webform_submission_presave function on a webform that I have created for a Drupal 7 site. Ideally I would like to capture a list of nodes that a user has flagged and transfer that data into a field before the user submits their form. But the function is just not adding the data.
First I get the flags:
$flags = flag_get_user_flags($node->type);
Then I want to transfer that variable into a field with a component ID of 30.
// Update some component's value before it is saved.
$component_id = 30;
$submission->data[$component_id]['value'][0] = $flags;
Here is the full function:
function MYMODULE_webform_submission_presave($node, &$submission) {
$nodes_list = array();
$title = '';
// Get the flags.
$flags = flag_get_user_flags($node->type);
// Update some component's value before it is saved.
$component_id = 30;
$submission->data[$component_id]['value'][0] = $flags;
}
What am I doing wrong? I'd love some help!
Comments
Comment #1
quicksketch$flags is an array of data. If you want to store that as a string, you'll need to convert it from an array into a string.
This is generally outside the scope of the issue queue, we specifically avoid programming questions to help reduce the noise in the issue queue. StackExchange or IRC might be better venues for help on this sort of thing. I'm going to mark this fixed as a support request to keep it visible, but this is about as much as we can provide in the Webform queue.