Add support for drupal webform composite fields

Created on 2 September 2024, 8 months ago

Problem/Motivation

Sometimes it would be needed to map ActiveCampaign handler fields to Webform composite sub-fields.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @dejan0
  • Status changed to Needs review 8 months ago
  • please find the patch attached.

  • First commit to issue fork.
  • πŸ‡§πŸ‡ͺBelgium dtfabio Ninove

    I will create an MR, apply the patch and test the code.

  • πŸ‡§πŸ‡ͺBelgium dtfabio Ninove

    Tested the code on Drupal version 10.4.6

    Will test on 10.3 and D11 next later.

  • πŸ‡§πŸ‡ͺBelgium dtfabio Ninove

    I get the following error on Drupal version 11.1.6:

    The website encountered an unexpected error. Try again later.
    
    TypeError: Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler::getMappedValue(): Return value must be of type string, null returned in Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler->getMappedValue() (line 248 of modules/contrib/activecampaign/modules/activecampaign_webform/src/Plugin/WebformHandler/ActiveCampaignFormHandler.php).
    Drupal\activecampaign_webform\Plugin\WebformHandler\ActiveCampaignFormHandler->submitForm() (Line: 2758)
    Drupal\webform\Entity\Webform->invokeHandlers() (Line: 1924)
    Drupal\webform\WebformSubmissionForm->submitForm()
    

    This happens when I use a custom composite field with several fields that are part of it. Then I get a nested array that the getMappedValue function cannot handle.

    I will add a check here to see if the value is an array, so this can be looped to return the correct value.

    Also think it might be good to return an empty string in case of a null value, to prevent this from happening for other currently unknown use cases as well.

  • πŸ‡§πŸ‡ͺBelgium dtfabio Ninove

    I will take this up further at Drupal Dev days Leuven.

  • πŸ‡­πŸ‡ΊHungary GΓ‘bor Hojtsy Hungary
Production build 0.71.5 2024