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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ultimike’s picture

Issue summary: View changes
ultimike’s picture

Issue summary: View changes
ultimike’s picture

Status: Active » Needs work
FileSize
7.07 KB

I 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

ultimike’s picture

Assigned: Unassigned » ultimike

I 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:

  'options.settings':
    plugin: field_instance_widget_settings
    source:
      - @type
      - constants.empty # we don't have any settings.
  'options.settings.display_label':  # use this if D6 CCK checkboxes work fine, otherwise do it in FieldInstanceWidgetSettings()->getSettings()
    plugin: static_map
    default_value: false
    source: type
    map:
      checkbox: true

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

ultimike’s picture

Status: Needs work » Needs review
FileSize
6.87 KB

After 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:

  1. MigrateDrupal6Test
  2. MigrateUserProfileEntityFormDisplayTest
  3. MigrateUserProfileFieldInstanceTest
  4. MigrateUserProfileFieldTest
  5. A manual test of a real-ish D6 database with several profile checkbox fields.

Thanks,
-mike

Status: Needs review » Needs work

The last submitted patch, 5: 2260239-5.patch, failed testing.

ultimike’s picture

Status: Needs work » Needs review
FileSize
9.23 KB

Ah - I missed some test setup() stuff in:

  1. MigrateUserProfileEntityDisplayTest
  2. MigrateProfileValuesTest

Let's try this again...

Thanks,
-mike

benjy’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_entity_form_display.yml
@@ -32,6 +32,12 @@ process:
+  'options.settings.display_label':

Might 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.

ultimike’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
9.33 KB

Added a comment per benjy's request.

Updated patch attached.

Thanks,
-mike

Status: Needs review » Needs work

The last submitted patch, 9: 2260239-9.patch, failed testing.

ultimike’s picture

Status: Needs work » Needs review

9: 2260239-9.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 9: 2260239-9.patch, failed testing.

ultimike’s picture

Status: Needs work » Needs review
FileSize
9.33 KB
811 bytes

I 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

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Yeah that previous fail was just a bot fluke.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 13: 2260239-13.patch, failed testing.

benjy’s picture

13: 2260239-13.patch queued for re-testing.

benjy’s picture

Status: Needs work » Reviewed & tested by the community

Was just the bot playing up. The automatic re-tests on RTBC issues are pain when we have random fails all the time.

webchick’s picture

Status: Reviewed & tested by the community » Fixed
+          'explanation' => "If you check this box, you love migrations.",

LOL :)

Committed and pushed to 8.x. Thanks!

  • Commit 181b122 on 8.x by webchick:
    Issue #2260239 by ultimike: D6->D8 Profile field (checkbox).
    

Status: Fixed » Closed (fixed)

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