Migrate Drupal Webform 6 or 7 in to Webforms in Drupal 8

Webform 8.x-5.x is a completely new code base, that takes a different, but familiar approach to solving the challenges of building rich, flexible, and maintainable client facing forms for a Drupal website. Webform 8-x-5.x includes many new features and leverages improvements in Drupal 8, including OO design patterns, extendable plugins, and automated tests.

The primary use case for this module is to:

So how do we get all the Drupal 6 or 7 webforms in to Drupal 8 is what we are going to details here. I did a little bit of research but I couldn't find any solution so I came up with this module Webform migrate to help with those kind of data migrations.

Webforms in D8 are configuration entities and submissions are content entities, Webforms OOP architecture clearly described each component in a very details oriented way so the migration set up was very easy.

So to get started please download the module here from GitHub and install it.

Then use the configuration import and use the migration templates available in the module and import them. If you set up the Migrate Plus module at the same time you install the Webform migrate module then during the migration it will look for those templates too. Either way get the configurations imported.

Once the configs are imported then you can run the migration to import Webform data, simple as that.

Sample configurations are below for Drupal 7 to Drupal 8 migration.

id: upgrade_d7_webform
label: 'Webform'
migration_tags:
  - 'Drupal 7'
migration_group: migrate_drupal_7
source:
  plugin: d7_webform
process:
  id: webform_id
  uid: node_uid
  title: title
  status: status
  elements: elements
  handlers: handlers
  access: access
  'settings/page':
    plugin: default_value
    default_value: 1
  'settings/page_submit_path': {}
  'settings/page_confirm_path': {}
  'settings/form_submit_label': submit_text
  'settings/form_exception_message': {}
  'settings/form_closed_message': {}
  'settings/form_confidential': {}
  'settings/form_confidential_message': {}
  'settings/form_prepopulate': {}
  'settings/form_prepopulate_source_entity': {}
  'settings/form_novalidate': {}
  'settings/form_autofocus': {}
  'settings/form_details_toggle': {}
  'settings/wizard_progress_bar':
    plugin: default_value
    default_value: 1
  'settings/wizard_progress_pages': {}
  'settings/wizard_progress_percentage': {}
  'settings/wizard_next_button_label': {}
  'settings/wizard_prev_button_label': {}
  'settings/wizard_start_label': {}
  'settings/wizard_complete':
    plugin: default_value
    default_value: 1
  'settings/wizard_complete_label': {}
  'settings/preview':
    plugin: default_value
    default_value: 0
  'settings/preview_next_button_label': {}
  'settings/preview_prev_button_label': {}
  'settings/preview_message': {}
  'settings/draft': allow_draft
  'settings/draft_auto_save': auto_save
  'settings/draft_button_label': {}
  'settings/draft_saved_message': {}
  'settings/draft_loaded_message': {}
  'settings/confirmation_type': confirmation_type
  'settings/confirmation_url': redirect_url
  'settings/confirmation_message': confirmation
  'settings/limit_total': total_submit_limit
  'settings/limit_total_message': {}
  'settings/limit_user': submit_limit
  'settings/limit_user_message': {}
  'settings/entity_limit_total': {}
  'settings/entity_limit_user': {}
  'settings/results_disabled': {}
  'settings/token_update': {}
destination:
  plugin: 'entity:webform'
migration_dependencies:
  required:
    - upgrade_d7_user_role
    - upgrade_d7_node_webform

Same for the submission data, you could use the migrate template available within the module and import using the configuration import.

id: upgrade_d7_webform_submission
label: 'Webform Form Submission'
migration_tags:
  - 'Drupal 7'
migration_group: migrate_drupal_7
source:
  plugin: d7_webform_submission
process:
  sid: sid
  webform_id: webform_id
  uri: Webform_uri
  created: submitted
  completed: submitted
  changed: submitted
  in_draft: is_draft
  current_page: {}
  remote_addr: remote_addr
  uid: uid
  langcode:
    plugin: default_value
    default_value: 'en'    
  entity_type:
    plugin: default_value
    default_value: 'node'    
  entity_id: nid
  sticky: {}
  notes: {}
  serial: {}
  data: webform_data
destination:
  plugin: 'entity:webform_submission'
migration_dependencies:
  required:
    - upgrade_d7_webform 

Download the module here.

Note : You can use Migrate Tools for Drush commands and Migrate Plus for some additional source and other plugins.

© Heshan Wanigasooriya.RSS

🍪 This site does not track you.