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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fjgarlin created an issue. See original summary.

fjgarlin’s picture

Status: Active » Needs review
FileSize
4.13 KB

Patch with suggested changes attached.

travis-bradbury’s picture

fjgarlin, 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.

fjgarlin’s picture

Agree, 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.

fjgarlin’s picture

This 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:

person[name]|first_name
privacy_and_tocs|Accept_Terms

This should also solve this ticket: https://www.drupal.org/project/webform_pardot/issues/3159187

fjgarlin’s picture

All 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.

fjgarlin’s picture

Removed var_dump... :facepalm:

travis-bradbury’s picture

That 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.

fjgarlin’s picture

Great additions to the patch! Thanks.

  • fjgarlin authored 5e111c4 on 8.x-1.x
    Issue #3174322 by fjgarlin, tbradbury: Map webform keys to Pardot keys
    
travis-bradbury’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.