Problem/Motivation
On existing webforms, if the field key differs to the Pardot one, then we either need to create a new field or alter the machine name, which would cause data loss from previous submissions.
Steps to reproduce
Pardot needs "e_mail" and webform field is set up as "email" so the submission won't be valid.
Proposed resolution
Create a new field to map webform keys to Pardot keys and apply that mapping right before sending info to Pardot.
Remaining tasks
Create a patch to add this new feature.
User interface changes
New field added below "Pardot post url".
API changes
None.
Data model changes
New setting will be exported in configuration.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | interdiff-3174322-7-8.txt | 4.56 KB | travis-bradbury |
| #8 | map_webform_keys_to_pardot_keys-3174322-8.patch | 7.97 KB | travis-bradbury |
| #7 | map_webform_keys_to_pardot_keys-3174322-7.patch | 6 KB | fjgarlin |
Comments
Comment #2
fjgarlin commentedPatch with suggested changes attached.
Comment #3
travis-bradbury commentedfjgarlin, do you think this could be a solution for #3159187: Flatten the data for Composite element of Webform too? If the mapping could handle composite elements it could probably solve both problems.
Comment #4
fjgarlin commentedAgree, I made a comment here https://www.drupal.org/project/webform_pardot/issues/3159187#comment-138... regarding the possible approach. I'll try to work on it.
Comment #5
fjgarlin commentedThis patch builds upon the previous. The UI remains the same but now we can map multiarray keys.
So if the Drupal array key is "person[name]" we can just put that in the mapping or "person.name" and it will map the individual values.
For example:
This should also solve this ticket: https://www.drupal.org/project/webform_pardot/issues/3159187
Comment #6
fjgarlin commentedAll the above, but also checks for Drupal checkboxes, which are rendered like "key[value]" but then mapped as normal arrays with numeric keys where the values are the "value".
ie: "subscriptions" with options "list1" "list2" will render as "subscriptions[list1]" and "subscriptions[list2]" but in the values will be "subscriptions => array(0 => "list1", 1 => "list2")".
This small addition will catch it and map it.
Comment #7
fjgarlin commentedRemoved var_dump... :facepalm:
Comment #8
travis-bradbury commentedThat looks really good to me.
This patch tweaked some comments - some string/array parameter types weren't correct.
It also adds instructions about the dot notation. I chose not to write about the ][ version since it seemed to be getting awkward to explain and it seemed fine to just give one way.
I also wrote a test for it. I didn't see a nice way to test it using public APIs so the test uses reflection to make the method public. That feels pretty dirty but at least it was easy.
Comment #9
fjgarlin commentedGreat additions to the patch! Thanks.
Comment #11
travis-bradbury commented