Pennebaker / craft-architect

A plugin for importing and exporting content models from Craft 3/4 using JSON.
MIT License
72 stars 6 forks source link

Error - Undefined index: label #58

Closed jayhlee closed 3 years ago

jayhlee commented 3 years ago

I'm getting an error (Undefined index: label) when I try to export my globals. Running Architect 2.4.1, Craft 3.6.10, PHP 7.4.16.

Any idea what's causing the issue? Thanks!

foreach ($fieldLayoutConfig[ 'tabs' ] as $tabConfig) {
    $fieldLayoutObj[$tabConfig['name']] = [];
    foreach ($tabConfig[ 'elements' ] as $elementConfig) {
        $fieldConfig = [
            'label' => $elementConfig['label'],
            'instructions' => $elementConfig['instructions'],
            'width' => $elementConfig|'width'],
        ];
spAnser commented 3 years ago

Do you have an example json that triggers this error?

jayhlee commented 3 years ago

@spAnser I can't generate an example json because the error is thrown before anything json is outputted. One of the globals that I'm getting the same error on is just a collection of text fields. I am using Nitro2 for my local dev. Not sure if that matters, especially because I was able to export my fields using Architect. Is there anything else I can do to provide you more info to diagnose what's going on?

spAnser commented 3 years ago

My apologies I thought it was during an import. I'll look more into it.

spAnser commented 3 years ago

Still can't seem to reproduce. I wonder if you go edit the global change nothing and click save if you still have the issue. Was this global made prior to Craft 3.5.x changes to field layout and maybe didn't migrate properly?

Also if you can share what your global looks like. I am also on the craft discord if you want to reach out we can try a few things.

jayhlee commented 3 years ago

Tried to save the global changes, but that didn't seem to do the trick. I think the globals were made post 3.5.x changes. I tried to reach out via Discord, although I'm not sure if I'm doing it right. Not too familiar with Discord. I sent a friend request, but let me know if there's a better way to communicate via Discord.

joepagan commented 3 years ago

hey @spAnser I was able to reproduce this when trying to export a channel.

If I disable just 1 field out of all which are pre-selected after selecting a channel then the export is successful???

If I just select the channel with 100% of the channel's fields to my export selection I get the same error as OP, to elaborate further the exception is: vendor/pennebaker/craft-architect/src/base/Processor.php line 422:

'label' => $elementConfig['label'],

My env: php7.2 craft 3.6.8 architect 2.4.1

I have attached the successful exported json of a channel minus 1 field: working-export.json.txt

After exporting the same channel with a different field here is what I would want for the full json:

            localizeRelations": false,
            "validateRelatedElements": false,
            "allowSelfRelations": false
        },
+        {
+            "group": "Meta",
+            "name": "Meta Description",
+            "handle": "metaDescription",
+            "instructions": "This tag provides a short description of the page. In some situations this description is used as a part of the snippet shown in the search results. [More information](https:\/\/support.google.com\/webmasters\/answer\/35624?visit_id=636801299720498059-2779965100&rd=1#meta-descriptions)",
+            "type": "craft\\fields\\PlainText",
+            "uiMode": "normal",
+            "code": "",
+            "multiline": "1",
+            "initialRows": "4",
+            "charLimit": "220",
+            "columnType": "text"
+        },
        {
            "group": "Meta",
            "name": "Meta Title",
            "handle": "metaTitle",

Maybe if you were to import this channel and fields you might experience the same issue?

spAnser commented 3 years ago

Thanks for the info I think if you updated to 2.4.2 the problem should go away. There was a few fixes in that version. If you still experience the same problem feel free to open a new issue so I can track it to a new fix.

joepagan commented 3 years ago

Ah thanks for the heads up! Will give that a shot. Update: can confirm 2.4.2 works