Add support for custom_field module

Created on 26 June 2025, 1 day ago

Problem/Motivation

Add support for the custom_field β†’ module, so entities using that field can be exported and imported using Default Content (or Drupal core recipe importer).

Export functionality for most custom_field data types are working out of the box, but the ones referencing entities will export the entity target IDs, rather than UUIDs used by the importer.

Steps to reproduce

- Install Default Content & custom_field
- Set up a custom_field field, containing (amongst others) an image field or entity reference field.
- Try export / import functionality.

Proposed resolution

- Add support for custom_field entity references in the Normalizer class.

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium svendecabooter Gent

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @svendecabooter
  • πŸ‡§πŸ‡ͺBelgium svendecabooter Gent

    Created an MR that updates custom_field data in the Default Content export for referenced entities.

    Original output without this MR:

    field_my_custom_field:
        -
          label: 'Exported label'
          image: 21 # Some random file ID
          image__width: 1024
          image__height: 1024
          image__alt: Sunset
          image__title: ''
          file: 22 # Some random file ID
          term: 4 # Some random taxonomy term ID
    

    After applying this MR. this becomes:

      field_my_custom_field:
        -
          label: 'Exported label'
          image: aa6340f0-0006-4f31-9f2d-5595f5cce028
          image__width: 1024
          image__height: 1024
          image__alt: Sunset
          image__title: ''
          file: c36ea199-cd17-4fe5-bec7-beef1ffb51b4
          term: 78ae1ee7-f2d4-4fc0-871e-1af92730df3b
    

    The referenced UUIDs also get added as a dependency to the "_meta" definition.

  • Pipeline finished with Success
    1 day ago
    Total: 189s
    #532339
  • πŸ‡§πŸ‡ͺBelgium svendecabooter Gent

    On the import side of things, there is a patch for custom_field that makes this work: πŸ“Œ Support Drupal core DefaultContent API Active .

  • πŸ‡§πŸ‡ͺBelgium svendecabooter Gent
  • πŸ‡§πŸ‡ͺBelgium svendecabooter Gent

    Attached is a patch file for the current state of the MR, useful for Composer based patching workflows.

  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    @svendecabooter,

    Building on my comment in https://www.drupal.org/project/custom_field/issues/3528586#comment-16166705 πŸ“Œ Support Drupal core DefaultContent API Active , it might just make best sense to create a reference type base class in custom_field that those 3 types extend so that this patch here can just depend on a single class. Forward thinking here in case we were to add new similar data types in custom_field so we don't have to go back and request a change again here.

  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    This patch would put a dependency on custom_field module. Needs to just check for the class as string vs. requiring the interface.

Production build 0.71.5 2024