Problem/Motivation
I am trying to put people into certain groups if they fill out certain forms on my site. I figured I could do this if I created a hidden field and set it to a certain values that anyone who fills out the form and opts into my newsletter will be added to that group. However if I use a hidden field component or if I set a component to private, the form throws an error upon submission.
Notice: Undefined index: items in webform_mailchimp_webform_submission_insert() (line 117 of webform_mailchimp/webform_mailchimp.module).
Notice: Undefined offset: 1 in webform_mailchimp_webform_submission_insert() (line 121 of webform_mailchimp/webform_mailchimp.module).
Notice: Undefined index: Wedding Contact Form in webform_mailchimp_webform_submission_insert() (line 124 of webform_mailchimp/webform_mailchimp.module).
However if I remove the "private" selection and expose the component, then the form submits correctly, I get no errors and the user is added to the correct group. Am I doing something incorrectly? Is there a better way to add someone to a group upon form submission?
Proposed resolution
Support single value components as well.
Remaining tasks
Review and Test Patch.
User interface changes
API changes
Original report by @waltercat
Comment | File | Size | Author |
---|---|---|---|
#4 | can_t_pass_interest-2177063-4.patch | 2.06 KB | joelpittet |
Comments
Comment #1
teamninja CreditAttribution: teamninja commentedI too have the same issue. We are passing some hard coded values in multiple input fields that we do not want the user to see when they are filling out the form.
Comment #2
adam_b CreditAttribution: adam_b commentedThe only way I've found to pass hidden values successfully is:
{display: none}
to hide the component from the end userIt's a bit of a hack, but it seems to work. I agree, it would be nice if the Hidden form component worked in this case.
Comment #3
joelpittetYes, I have this issue true:
Seems to be related to this snippet of code:
Comment #4
joelpittetCan someone give this patch a try?
It should do both hidden and select/options.
Comment #5
joelpittetThis isn't part of the patch, but it looks suspicious
str_replace(",", "\," ...
, Anybody want to also confirm that that still works with webform 4.x and mailchimp module 3.x?Comment #6
joelpittetComment #7
CatherineOmega CreditAttribution: CatherineOmega commentedJoel, I haven't been able to get that to work, I'm afraid. I'm wondering if it's partly due to the fact that I'm populating the hidden field with JavaScript, or if I'm missing something about how Mailchimp assigns names to groups?
Comment #8
joelpittetIt may be due to the js population @CatherineOmega, but you'd need to do a simple test case with the FAPI to see if the values get posted after JS populates them.
Or if you have an IDE like PHPStorm or Eclipse, set a breakpoint in the submit handler and ensure your JS comes across.
Comment #9
CatherineOmega CreditAttribution: CatherineOmega commentedOkay, nope. It appears that interest groups don't work at all in Webform 4.x and Mailchimp module 3.x, at least when it comes to webform_mailchimp. I'm continuing further testing to see if it's because of Mailchimp module or what.