Problem/Motivation
WebformLikert webform component always expects default value to be associative array, where keys are questions and values are answers. In D7 version, it's allowed to have default as a string this, which means that this answer should be default for all available questions.
1) Current migration does not support default value in array format;
2) Current migration does not handle transition D7 grid string value -> D8 WebformLikert array value;
Expected yml:
test_element:
'#type': webform_likert
'#questions':
'1': 'Which one?'
'#answers':
'1': 'First'
'2': 'Second'
'#default_value':
1: '1'
Steps to reproduce
Migrate a webform with grid element and default value.
Proposed resolution
1) Add array support for default value;
2) Prepare default values for WebformLikert component;
Remaining tasks
1) Wait until #3172139: Enable project testing, and add a kernel test and a source database and files fixture is landed;
2) Update the database fixture and tests;
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | Selection_186.png | 10.03 KB | hitchshock |
| #5 | Selection_187.png | 52.5 KB | hitchshock |
| #2 | webform_migrate-3206913-2.patch | 1.72 KB | matroskeen |
Issue fork webform_migrate-3206913
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
matroskeenHere is an initial patch. It was created on top of #3185234: Single quotes are not escaped properly for select element options and element names, so it won't apply. Leaving as NW for now.
Comment #5
hitchshockNot only the migration of the default value that is an issue, the options and questions are also not migrated correctly.
D7 values (options/questions) looks like this:
1|First\n\r2|Second\n\r3|ThirdThis is a required D7 structure: "safe_key|Some readable option"
In the result we have to receive the following array of the options/questions according to the webform component behaviour:
But at the moment the result looks like this:
As the result, the data migrated incorrectly:


Fixed the issue around default value/options/questions migration and updated the test data.
[@matroskeen] It will be good to update the title to
Default value/options/questions for WebformLikert webform element are not migrated properly
Comment #6
hitchshockAlso, fixed a similar issue for the migration of the Select and EMail components.
Comment #7
joelpittetThough I got a notice while running the migrations to fix this issue, it worked great and solved the problem of the WebformLikeRt errors.
New notice was:
[warning] Undefined array key 1 D7Webform.php:991Comment #8
joelpittetFixed that caveat by trimming the raw value to remove whitespace before and after the values.
Comment #9
joelpittetUsing this with 2.x
Comment #10
joelpittetHave one issue where the first column misses values (most of the time, I saw one numeric one migrate fine).
Comment #14
joelpittetBack to RTBC, the problem I ran into was a separate issue, this MR doesn't affect submissions, I will create a separate issue for that.
Comment #16
ruslan piskarovComment #17
joelpittetThanks for getting this in!
Comment #19
hitchshock@ruslan-piskarov
An interesting way to handle credits of the ticket...
Comment #20
ruslan piskarovHi @hitchshock, I am not sure what I did wrong. As I see you and @joelpittet were tagged.
It's strange that you weren't credited.
I'm going to see how I can fix this.
Comment #21
hitchshockThanks, that didn't ignore me ^_^