field-manager icon indicating copy to clipboard operation
field-manager copied to clipboard

Cannot export/import Neo Field Layout

Open xinnings opened this issue 2 years ago • 5 comments

Question

I try to export and import a Neo Field, the Block Types and Settings are good, but the Field Layout is empty, any idea why?

fieldLayout example in exported json file

                    "fieldLayout": {
                        "tabs": [
                            {
                                "name": "Content",
                                "sortOrder": 1,
                                "elements": [
                                    {
                                        "type": "craft\\fieldlayoutelements\\CustomField",
                                        "label": "",
                                        "instructions": "",
                                        "tip": null,
                                        "warning": null,
                                        "required": 1,
                                        "width": 100,
                                        "fieldUid": "77b011c9-c556-4278-b33d-a286bcdcf36a"
                                    },
                                    {
                                        "type": "craft\\fieldlayoutelements\\CustomField",
                                        "label": "",
                                        "instructions": "",
                                        "tip": null,
                                        "warning": null,
                                        "required": 1,
                                        "width": 100,
                                        "fieldUid": "d7d4a902-9d6e-4e6d-bb86-a23fa1148d92"
                                    },
                                    {
                                        "type": "craft\\fieldlayoutelements\\CustomField",
                                        "label": null,
                                        "instructions": null,
                                        "tip": null,
                                        "warning": null,
                                        "required": false,
                                        "width": 100,
                                        "fieldUid": "120a61e5-003a-4f13-ad14-e405f932bb27"
                                    }
                                ]
                            }
                        ]
                    }

Additional context

Craft cms: 3.7.46 Field Manager:2.2.5 Neo: 2.13.15

xinnings avatar Sep 05 '22 07:09 xinnings

Are you also exporting the fields used in your Neo block types? Field Manager won't create them for you, and expects them to either be present already on the install you're importing into, or part of the import a separate fields you're also importing with your Neo field.

Otherwise, we end up with duplicate fields, and creating fields used in Neo blocks, which are outside of the Neo field scope (unlike Matrix and Super Table).

engram-design avatar Sep 06 '22 11:09 engram-design

Yes, I was also exporting the fields used in my Neo block types, together with Neo fields. the block types of Noe are imported, just the layout is empty, I have to manually add them.

xinnings avatar Sep 07 '22 01:09 xinnings

Thanks for confirming. I can't seem to replicate this at the moment, but will keep testing.

engram-design avatar Sep 07 '22 06:09 engram-design

Hi,

the problem is, that the export doesn't store the uid from the field. If you import the field into another installation, the field will be added, but with another uid. Therefore a "custom field layout" in neo fields could not be (re-)find, because no matching field uid. A solution could be to export the uid of the field and also use them in the import.

The problem is also present in Craft 4.x...

sfsmfc avatar Dec 08 '22 11:12 sfsmfc

Yeah, so Neo (and other fields that use already-existing fields) pose a bit of an issue for Field Manager, because it expects it to bundle both the Neo field and in linked fields. Currently, the plugin expects the linked field to already exist on the install, and won't import them alongside Neo fields.

As for exporting the fields, they do contain the UID of the block type fields. See an example export below.

[
    {
        "name": "Neo Field",
        "handle": "nodeField",
        "instructions": null,
        "required": null,
        "searchable": false,
        "translationMethod": "site",
        "translationKeyFormat": null,
        "type": "benf\\neo\\Field",
        "settings": {
            "minBlocks": null,
            "maxBlocks": null,
            "minTopBlocks": null,
            "maxTopBlocks": null,
            "minLevels": null,
            "maxLevels": null,
            "propagationMethod": "all",
            "propagationKeyFormat": null,
            "blockTypes": {
                "new1": {
                    "name": "Content",
                    "handle": "contentBlock",
                    "sortOrder": 1,
                    "maxBlocks": 0,
                    "maxSiblingBlocks": 0,
                    "maxChildBlocks": 0,
                    "childBlocks": null,
                    "topLevel": true,
                    "fieldLayout": {
                        "tabs": [
                            {
                                "name": "Content",
                                "uid": "653be348-8366-4be2-bd4d-8f1d67ed22fe",
                                "userCondition": null,
                                "elementCondition": null,
                                "elements": [
                                    {
                                        "type": "craft\\fieldlayoutelements\\CustomField",
                                        "label": null,
                                        "instructions": null,
                                        "tip": null,
                                        "warning": null,
                                        "required": false,
                                        "width": 100,
                                        "uid": "aefb6c43-48c9-4743-ac6b-d2a0702198e9",
                                        "userCondition": null,
                                        "elementCondition": null,
                                        "fieldUid": "8dafeb23-8c42-4b70-a63f-94858860779d"
                                    }
                                ]
                            }
                        ]
                    }
                }
            }
        }
    }
]

That fieldUid corresponds to the fields database table row.

We can't (and probably shouldn't) rely on the UID of a field to be exactly the same no matter where we're importing it. It's by nature that when importing fields things should get a new UID (unique to that install).

So this is a known-issue that we don't import the linked Neo fields into new installs - unless they also exist (by handle) there. It's something we'll look at.

engram-design avatar Dec 10 '22 01:12 engram-design