Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot export/import Neo Field Layout #89

Open
xinnings opened this issue Sep 5, 2022 · 5 comments
Open

Cannot export/import Neo Field Layout #89

xinnings opened this issue Sep 5, 2022 · 5 comments
Labels

Comments

@xinnings
Copy link

xinnings commented Sep 5, 2022

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

@engram-design
Copy link
Member

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).

@xinnings
Copy link
Author

xinnings commented Sep 7, 2022

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.

@engram-design
Copy link
Member

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

@sfsmfc
Copy link

sfsmfc commented Dec 8, 2022

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...

@engram-design
Copy link
Member

engram-design commented Dec 10, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants