I am a real person that used AI to write this bug report. The information is accurate and describes an issue I encountered while trying to use this module to sync data from webforms to google sheets. I've attached a patch that corrected the issue on my end.
Problem/Motivation
When a webform contains a textarea with a text format enabled (e.g., "Plain text", "Basic HTML"), the Google Sheets handler silently drops the field's value from the submission data sent to the spreadsheet. All other fields submit correctly, but text format fields are missing with no error or warning.
This occurs because Drupal stores text format field values as an associative array (['value' => '...', 'format' => 'plain_text']) rather than a plain string. In WebformGoogleSheetsHandler::getData(), the !is_array($value) check on line 546 causes these fields to fall into the array processing branches (composite, likert, webform_multiple), none of which match, so the value is never added to $flat_data.
Steps to reproduce
- Create a webform with a Textarea element.
- On the element's settings, set Text format to any format (e.g., "Plain text").
- Add a Google Sheets handler to the webform and ensure the textarea field is included under "Submission data."
- Submit the webform.
- Check the Google Sheet — the textarea column will be empty while all other non-text-format fields are populated correctly.
Proposed resolution
Before the !is_array($value) single-value check, detect text format field arrays by checking for the presence of both 'value' and 'format' keys. If matched, extract the 'value' key so the field is treated as a plain string and processed normally.
if (is_array($value) && array_key_exists('value', $value) && array_key_exists('format', $value)) {
$value = $value['value'];
}
Remaining tasks
Review and commit the patch.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| webform-googlesheets-text-format-fields.patch | 710 bytes | robv |
Issue fork webform_googlesheets-3576835
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
robv commentedComment #5
elamanI've added some unit tests to go with it.
Comment #7
elamanComment #10
elamanThe formatted text fix changes the number of cells exported by existing handlers because these elements were previously selected but silently omitted.
MR !35 adds a post-update that excludes single-value formatted text elements from existing Google Sheets handlers. This preserves the existing spreadsheet column layout after an upgrade. Administrators can select the fields again after adding the corresponding columns to their sheets. New handlers are not affected.
The update is covered by a kernel test that also confirms ordinary text fields remain selected.
Comment #12
elaman