Hey,
When submitting a webform that contains a commerce_webform component the value for any addressfield (in webform submissions) is removed. It looks like this is because addressfield_tokens unserializes the address in hook_webform_submission_load().
According to this comment from #1523364: How do I save array (checkbox) values in a custom component?:
Use _webform_submit_[component_name]() in your custom component. See how the date, time, and file components convert the data from arrays into string values in their submit functions.
Looking at those components it seems you should unserialize the data in the appropriate component display hook (eg. see _webform_display_date(), _webform_table_date() etc.).
It might be related to #1828426: Notice: unserialize() [function.unserialize]: Error at offset 0 of 5 bytes and #2614470: Can't change country when editing a webform submission but I haven't checked.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | addressfield_tokens-unserialize_on_display-2674752-13-d7.patch | 5.91 KB | rmcom |
| #3 | addressfield_tokens-unserialize_on_display-2674752-3-d7.patch | 5.27 KB | andyf |
Comments
Comment #2
andyf commentedComment #3
andyf commentedThanks!
Comment #4
rmcom commentedThis patch is important and works well with 7.x-1.6.
Please add it to the next version.
Comment #5
andyf commented@rmcom Thanks for confirming it works for you; if one or two others do the same we can mark it as Reviewed & tested by the community. Just so you know, the status Path (to be ported) is for patches that need to be ported to a different major version of Drupal.
Comment #6
lambic commentedThis patch doesn't look right to me, why is the hook_webform_submission_load implementation being removed?
Comment #7
lambic commentedComment #8
andyf commented@lambic Thanks for taking a look.
I've forgotten some of the specifics now, but the summary I think basically describes the problem. I was investigating an issue with vanishing address values in a webform and couldn't find any explicit documentation for how to implement multi-value webform components (IIRC) but I found the linked issue with a comment from quicksketch. He suggested using the date/file modules as examples. They take a scalar value in the component display hook and then create the necessary render array; there are two examples in the summary, and also see also
_webform_display_file().So my understanding was/is
hook_webform_submission_load()is the wrong place for deserializing which is why it's gone. The bug only manifested when used with commerce_webform but the solution seemed to be to update addressfield_tokens. Sorry I can't remember more about it now.Comment #9
rmcom commentedWould it please be possible to integrate this into the next release. Until this is done, each update generates a major problem for each site using commerce_webform (which is the case for currently over 1,150 websites)?
Thank you so much!!
When the changes by AndyF are applied, the issue disappears while, at the same time, none of the functionality of this great module is lost.
Comment #10
lambic commentedPatch doesn't apply currently, looks like it needs a reroll.
Comment #11
hass commentedComment #12
tmai82 commentedPlease implement this patch, every update breaks our online registration system that uses webform commerce. This patch addresses the issue and fixes it, but it's tiring to redo it every time there is an update.
Comment #13
rmcom commentedAttached please find the patch to fix this issue.
This patch also makes this module compatible with Webform 7.4 by:
- '#required' => $component['mandatory'],
+ '#required' => $component['required'],
Comment #15
lambic commentedThanks for the new patch, it has been applied in the 7.x-1.x branch.
Comment #16
lambic commented