id: d6_field_instance_widget_settings
label: Field instance widget configuration
migration_tags:
  - Drupal 6
  - Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: alterFieldWidgetMigration
source:
  plugin: d6_field_instance_per_form_display
  constants:
    entity_type: node
    form_mode: default
    third_party_settings: { }

process:
  # We skip field types that don't exist because they weren't migrated by the
  # field migration.
  field_type_exists:
    -
      plugin: migration_lookup
      migration: d6_field
      source:
        - field_name
    -
      plugin: extract
      index:
        - 1
    -
      plugin: skip_on_empty
      method: row
  bundle:
    -
      plugin: migration_lookup
      migration: d6_node_type
      source: type_name
    -
      plugin: skip_on_empty
      method: row
  form_mode: 'constants/form_mode'
  field_name: field_name
  entity_type: 'constants/entity_type'
  'options/weight': weight
  'options/type':
    type:
      plugin: static_map
      bypass: true
      source: widget_type
      map:
        number: number
        email_textfield: email_default
        date_select: datetime_default
        date_text: datetime_default
        date_popup: datetime_default
        imagefield_widget: image_image
        phone_textfield: telephone_default
        optionwidgets_onoff: boolean_checkbox
        optionwidgets_buttons: options_buttons
        optionwidgets_select: options_select
        nodereference_select: options_select
        nodereference_buttons: options_buttons
        nodereference_autocomplete: entity_reference_autocomplete_tags
        userreference_select: options_select
  'options/settings':
    -
      plugin: field_instance_widget_settings
      source:
        - widget_type
        - widget_settings
  'options/third_party_settings': 'constants/third_party_settings'

destination:
  plugin: component_entity_form_display
migration_dependencies:
  required:
    - d6_field_instance
