Add configuration for how to format field values when sending to CiviCRM

Created on 14 February 2023, almost 2 years ago
Updated 11 October 2023, about 1 year ago

Problem/Motivation

Currently, there is no means of altering the format of field values to send to CiviCRM. This leads to problems when not using only select or Textfield fields, but more advanced types like Text Format or Date for webform fields, as they produce more output than just a single string value, i.e. they are not rendered but present their values in a type-specific data structure (e.g. {"value": "...", "format: "full_html"} for Text Format type fields.

Steps to reproduce

Create a Text Format type field in your webform with the name (field key) of one of your Form Processor inputs. Submit the webform and notice the value being a JSON string with the type-specific structure of the Text Format field type.

Proposed resolution

Add configuration options for selecting the format for each field that is to be sent to the Form processor, similar to each field's Submission View settings.

Remaining tasks

MR is already being prepared. Tests (with regular field types created by the module and as many "special" Webform field types as possible).

User interface changes

In the Form Processor handler's configuration form, there's a new fieldset named Submission settings in the Advanced tab with a table for the mapping of configurable formats per field. There is no more customization (as in the Submission View settings you're able to define custom formats - this is not yet implemented for the Submission settings)

API changes

None.

Data model changes

Additional configuration option $configuration['submission_settings']['fields'][$key]['format']

Comments

I used Webform's method buildExportRecord() for each element to render its value, as those implementations already take care of deciding whether to render for HTML or raw text. We can actually consider sending values to CivICRM as some kind of export, so this makes sense to me. Let me know if there are implications I'm not aware of.

Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany jensschuppe

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

Comments & Activities

  • Issue created by @jensschuppe
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany jensschuppe

    I added some mitigation for not breaking submissions for select type elements, as the default format in the configuration form would be Default (value), which maps to the option label instead of its value. So for those elements, there should now be a default format of Raw value instead, as otherwise this would have introduced a regression.

    We're currently testing this, especially whether the default config form value is being selected correctly, and whether select fields without a configured submission format still behave correctly.

  • @jensschuppe opened merge request.
  • 🇳🇱Netherlands Klaas Culemborg

    I just this a user test. It is possible to send a text format field that is configured to have rich text to CiviCRM. You also to use a rich text filed in CiviCRM.

    • jensschuppe committed f8823408 on 2.0.x
      Issue #3341602: Add configuration for how to format field values when...
  • Status changed to Fixed about 1 year ago
  • 🇳🇱Netherlands jaapjansma

    This is fixed for a while now.

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

Production build 0.71.5 2024