Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
During manual testing of the D6->D8 migration, I noticed that a D6 field of type "checkbox" is migrated to D8 as a list, and not a single on/off checkbox.
Proposed resolution
Use a D8 list_boolean field type with OnOffWidget.
Remaining tasks
User interface changes
API changes
Original report by @ultimike
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff.txt | 811 bytes | ultimike |
#13 | 2260239-13.patch | 9.33 KB | ultimike |
Comments
Comment #1
ultimikeComment #2
ultimikeComment #3
ultimikeI worked on this for a bit this afternoon, made some progress, but not a total success yet.
I was able to set the field type to "list_boolean" and the form widget to "Single on/off checkbox", but to finish the job, I think the "display_label" setting for the "Single on/off checkbox" needs to be set to true (it defaults to false).
I've attached a patch with what I've done so far (including modifying the MigrateUserProfileEntityFormDisplayTest.php to check for the proper field type and display_label value), but would gladly accept some guidance on setting the display_label properly (it is set to false by default, but should be set to true otherwise the checkboxes don't have any labels). I messed around with adding a static map to the d6_user_profile_entity_form_display.yml that would default to "constants.empty" for everything except @type=options_onoff, but couldn't make it work.
Thanks,
-mike
Comment #4
ultimikeI chatted with benjy this morning on IRC and he gave me a couple of ways to attack the display_label stuff:
If this is only an issue with profile field checkboxes, then we should be able to fix it in the d6_user_profile_entity_form_display.yml with something like:
If this is also an issue with D6 CCK checkboxes, then a more general solution can be done in FieldInstanceWidgetSettings()->getSettings(). We can pass the source $row in and set the display label based on the source type.
I'll work on this later today.
Thanks,
-mike
Comment #5
ultimikeAfter working on this a bit more, I went ahead and spun off the CCK Single on/off checkbox stuff into a different issue (https://drupal.org/node/2262275), as they're really a bit of a different beast. When using the CCK Single on/off checkbox widget, the fieldtype can be a decimal, float, integer, or text, so there's going to have to be some CCK-specific logic that doesn't really apply to profile fields.
Profile checkboxes are always integers (0 or 1), so this patch only takes care of them. I tested this patch by running:
Thanks,
-mike
Comment #7
ultimikeAh - I missed some test setup() stuff in:
Let's try this again...
Thanks,
-mike
Comment #8
benjy CreditAttribution: benjy commentedMight be worth a comment to clarify why we only set display_label for checkbox.
I don't think that should hold this issue up though as everything else looks good.
Comment #9
ultimikeAdded a comment per benjy's request.
Updated patch attached.
Thanks,
-mike
Comment #11
ultimike9: 2260239-9.patch queued for re-testing.
Comment #13
ultimikeI don't understand - all I did was add a comment - is this a testbot fail?
I just regenerated the patch along with an interdiff...
Thanks,
-mike
Comment #14
benjy CreditAttribution: benjy commentedYeah that previous fail was just a bot fluke.
Comment #16
benjy CreditAttribution: benjy commented13: 2260239-13.patch queued for re-testing.
Comment #17
benjy CreditAttribution: benjy commentedWas just the bot playing up. The automatic re-tests on RTBC issues are pain when we have random fails all the time.
Comment #18
webchickLOL :)
Committed and pushed to 8.x. Thanks!