verbb / hyper

A Craft CMS plugin for managing links, focusing on user experience.
Other
22 stars 13 forks source link

Field Layouts not working when having a Hyper field in multiple Matrix Blocks #50

Closed michtio closed 1 year ago

michtio commented 1 year ago

Describe the bug

When create a new Matrix Field, and you add the Hyper Field to multiple Matrix blocks, there is an issue with adding custom fields into the field layout. When the fields are added and saved correctly in the Matrix blocks, when going to the entry containing these blocks don't show the custom added fields onto Hyper in the Matrix block types. It shows the standard Field Layout, no matter if you add custom fields or deleted the fields already added.

Steps to reproduce

  1. Create a fresh new Matrix Field
  2. Add a new Block Type
  3. Create the Hyper field and add any field into one of the basic tabs that Hyper providers. ( handle: hyper )
  4. Add a new Block Type
  5. Repeat step 3 ( handle: hyper )
  6. Go back to the first Block Type click the Hyper Field, and notice that the custom added field has disappeared
  7. Add the custom field again into the field layout
  8. Go back to the second Block Type click the Hyper Field, and notice that the custom added field has disappeared
  9. Add the custom field again into the field layout
  10. At this point you'll see both custom fields added in the custom field layout on both Block Types
  11. Click save --> it says the Field is saved correctly without any errors
  12. Add the field to an Entry Type, save the entry type
  13. Go to the section with the entry type, containing the matrix with the 2 blocks
  14. Click on the first block that contains the Hyper field --> the custom field added to Hyper is not visible
  15. Click on the second block that contains the Hyper field --> the custom field added to Hyper is not visible

As an extra: If you delete the standard fields already added ( e.g. Classes ) and you remove that field, save the block type, you'll see that field appear in the Matrix Block Type, even tho it's not supposed to be there.

  1. Go back to the matrix field --> block type --> click the Hyper field. And you'll see the Field Layout seems to be saved correctly.

Craft CMS version

4.4.7.1

Plugin version

1.1.4

Multi-site?

No

Additional context

Used plugins:

"require": {
        "php": "^8.0.2",
        "craftcms/aws-s3": "^2.0.3",
        "craftcms/ckeditor": "^3.0.0",
        "craftcms/cms": "^4.4.7",
        "nystudio107/craft-closure": "^1.0.0",
        "nystudio107/craft-eagerbeaver": "^4.0.2",
        "nystudio107/craft-imageoptimize": "^4.0.4",
        "nystudio107/craft-minify": "^4.0.0-beta.2",
        "nystudio107/craft-retour": "^4.1.12",
        "nystudio107/craft-seomatic": "^4.0.23",
        "nystudio107/craft-similar": "^4.0",
        "nystudio107/craft-typogrify": "^4.0.1",
        "nystudio107/craft-vite": "^4.0.5",
        "putyourlightson/craft-blitz": "^4.4.4",
        "putyourlightson/craft-blitz-recommendations": "^2.1.1",
        "putyourlightson/craft-elements-panel": "^2.0.0",
        "putyourlightson/craft-sherlock": "^4.3.0",
        "spicyweb/craft-embedded-assets": "^3.1.4",
        "verbb/formie": "^2.0.26",
        "verbb/hyper": "^1.1.4",
        "verbb/super-table": "^3.0.8.1",
        "vlucas/phpdotenv": "^5.4.1",
        "yiisoft/yii2-redis": "^2.0.18"
    },
michtio commented 1 year ago

@engram-design I created a repo that show the issue here: https://github.com/michtio/hyper-bug using spin-up-craft :)

engram-design commented 1 year ago

Thanks, I can't seem to get that to work, as it's error after error for me with that repo, and getting it started! I can also see the database, but it's essentially empty. Did you need to export it?

Anyway, I was able to rebuild the site from the Yaml files. From what I can tell, it's all working correctly. You've just modified the field layout just for the Assets link type, nothing else. Because field layouts are unique to each link type, so you can tailor different fields for different link types, you'll need to make several updates.

image image

For example, if I enable Asset link types, I can see custom fields you've defined.

image
michtio commented 1 year ago

Thanks @engram-design!

Although it's a bit confusing to have to do that. Is there an easy way to copy field layouts, or could an option "all field layouts per link type is the same".

That would make a lot of sense!

michtio commented 1 year ago

About the repo. It's supposed to be running in the browser with spin-up-craft from Andrew. Might coordinate why it doesn't work as intended.

engram-design commented 1 year ago

Nothing like that available yet, but I’ll add it to our todo list.

Ah, that’s might explain it. I’ll hit Andrew up about it!

michtio commented 1 year ago

Thanks @engram-design. I'll close the issue for now since it's a current none-issue.