Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

huzooka created an issue. See original summary.

huzooka’s picture

Title: Fix the migration of nested values, multi-value field types (e.g. checkboxes) and handle 'grid' type submission values » D7 Fix the migration of nested values, multi-value field types (e.g. checkboxes) and handle 'grid' type submission values
Assigned: huzooka » Unassigned
Status: Active » Needs review
FileSize
1.8 KB
oldspot’s picture

Thanks a lot for this patch! It's helped a lot.
I've been testing it on a migration I'm currently working on and I thought initially that everything worked great as it migrating all the checkboxes, and other elements perfectly, however I've started to run into some issues once I started actually testing the webform itself and try to submit the form.
Not too sure whether there's something in particular with my source webforms but I'll do my best to explain the situation:
It seems the issue only happens with migrated 'checkbox' elements ('checkboxes' work great). Whenever I try to submit the form
I get the error on the page "An illegal choice has been detected" with the error in Drupal being "Illegal choice 1 in Example element."

This happens because the checkbox in D8 sets the value 0 if unticked or the value 1 if ticked.

And the checkboxes in D7 are required to have the 'Options' field set to a key-value pair such as "safe_key|Some readable option".
So unless that safe_key is 0 or 1 the above error happens.

As far as I can tell the Checkbox is migrated that way when there's only one option in the D7 Select fields and 'multiple' is checked, in which case it sets a yml value in the 'Custom properties' Advanced section of the checkbox element.
However when creating a Checkbox element manually in D8 that element is 'simple' and hasn't got any custom properties and its value is simply a 1 or a 0.

I'm going to investigate a bit more different options and see what the expected outcome should be. I've got several of these 'Checkbox' elements and it's a really difficult situation, as I've got some that happen to have only one option set, but they should be 'Checkboxes' element for that particular one, but then I've got others that are legitimately a 'Checkbox' but in D7 they happened to have a custom 'key' in the option (ie. a 'yes' instead of a 1).

On another note, I've noticed that the conditionals for those Checkbox elements are also broken as the conditional gets set to a custom value of :input[name="example_element[safe_key]"] whereas D8 expects it to be just :input[name="example_element"] as it's a simple Checkbox.

oldspot’s picture

Sorry got the wrong issue! Just realised this is the one with the patch for webform submissions!
I was thinking of the closed issue #3102325: Several fixes in the webform structure migration + the newer one #3174398: Wrong implementation for checkboxes and checbox

I was thinking of adding this to the open 3174398 one, though the issues in that one with checkboxes were actually fixed by the release to dev of the closed issue 3102325.
So instead I'll open a new issue for this 'checkbox' problem I've got.

oldspot’s picture

Status: Needs review » Reviewed & tested by the community

And in fact I'll move this issue to RTBC as I've migrated nearly 100k submissions yesterday and after doing several spot checks the values for checkboxes migrated great (in fact I had issues and it errored out before applying this patch due to the $item variable being treated as an array when it was a string)

  • andr1yun committed 5c71206 on 8.x-1.x authored by huzooka
    Issue #3172176 by huzooka: D7 Fix the migration of nested values, multi-...
andriyun’s picture

Status: Reviewed & tested by the community » Fixed

Fixed
Thx @oldspot @huzooka

Status: Fixed » Closed (fixed)

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