The issue is this: The emf_mailchimp plugin simply passes on the values it gets for the 'type' of custom fields. However, the emf module expects different values specifying the type (e.g., mailchimp's 'dropdown' is emf's 'select_one').
This manifests only in one place: In the form for anonymous users. The custom fields simply do not show up. I banged my head against the wall for a while, but finally figured out what the problem was.
To replicate:
- Create a 'dropdown' field for a list in mailchimp.
- Run cron to sync the list to your drupal installation.
- Mark the new field as 'Ask Anonymous' in the 'Field mappings' screen.
- Log out.
- Navigate to the subscribe-page of the list in question (or a page that includes the subscribe-block for the list).
- Observe that the new field does not occur in the subscription form.
The attached patch solves this issue by
- Giving an additional argument to the helper function
_emf_mailchimp_api_get_array_call
, an array of arrays, indexed by 'local field' names. The values are arrays mapping API values to emf values (e.g.'dropdown' => 'select_one'
). - Modifying the helper function
emf_mailchimp_api_get_custom_fields
to make use of this extra argument to translate the API values into the local values. - For uniformity, I also gave
_emf_mailchimp_api_get_scalar_array_call
an additional argument, serving the same function.
After applying the patch, you have to re-run cron to re-sync the lists---because the relevant API function is only called during syncing. To verify that the patch works, repeat the replication steps above, except for the last one ;)
Maybe it would be nice, in the long term, to provide more direct support for more of the mailchimp API types (e.g. 'radios', which the patch simply maps to 'select_one', resulting in a <select>
), but for now, the patch at least makes sure that everything shows up (and solves all the problems I have).
Comment | File | Size | Author |
---|---|---|---|
emf_mailchimp-transcode-field_type-values.patch | 3.1 KB | sven.lauer |
Comments
Comment #1
gilgabar CreditAttribution: gilgabar commentedThe $value_map in _emf_mailchimp_api_get_scalar_array_call() throws a bunch of php warnings because nothing is being passed to it. So it could use an empty array as a default value similar to _emf_mailchimp_api_get_array_call().
Also this is minor, but there should be some extra spaces, so this:
should look like this:
Otherwise it appears to work correctly for me.