Problem/Motivation

When I try to import content using the default_content module, the display id is not set.

From the json file exported using default_content:

    "leggodt_view_field": [
        {
            "target_id": "services",
            "display_id": "block_1",
            "arguments": "",
            "lang": "en"
        }

After importing, the database looks like this:

Proposed resolution

Ensure that the display_id and arguments are properly imported.

The database should look like this after import:

Comments

John Cook created an issue. See original summary.

john cook’s picture

Status: Active » Needs review
StatusFileSize
new1.25 KB

After looking into this problem, it turns out that the default normalizer for reference field (which viewfield entries are one of) only use the target_id value from the imported data.

I've created a new normalizer for viewfield entries to fill in the missing data.

This should also fix any service based importing of viewfields.

socialnicheguru’s picture

Status: Needs review » Needs work

On Drupal 8.4.2 I think the hal module is a dependency now

Error here:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The [error]
service "viewfield.entity_reference_item" has a dependency on a non-existent service
"hal.link_manager". in
drupal-8.4.0/vendor/symfony/dependency-injection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php:58

maxilein’s picture

jerdavis’s picture

HAL is not required for the export of normal entity reference fields. I'd like to understand why we can't affect this without enabling HAL? If we have to enable HAL, I'd almost prefer that this be moved into a sub module so it was optional to enable it. I'd like to have further discussion here prior to merging this.

maxilein’s picture

I think I had this error simply after upgrading or enabling of the module ... I never imported anything.
Enabling HAL made the error go away.

jerdavis’s picture

You wouldn't get this error with Viewfield unless you applied the patch on this issue which requires HAL. My point was that HAL isn't required to be enabled for Entity Reference fields, so I'd hoped we could provide an alternative solution for this issue that didn't require HAL to be enabled. Baring that, I'd ask that this patch be split and added to a sub-module for API integration for Viewfield so it's not required on all sites. A site that isn't using API access or default content with Viewfield shouldn't require this code or the HAL module being enabled.

  • jerdavis committed 4ace3d0 on 8.x-3.x
    Issue #2890761 by John Cook: Viewfields do not properly import with...
jerdavis’s picture

Status: Needs work » Fixed

Reworked to follow Entity Reference Revision's methodology and include a ViewfieldServiceProvider class that will conditionally provide a service definition based on the enabled state of the HAL module.

Status: Fixed » Closed (fixed)

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