verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Field Layout not added in project config files #88

Closed ryguy2407 closed 1 year ago

ryguy2407 commented 2 years ago

I create a new Vizy block on my local install and assign fields to the block in the field layout for the newly created block but when I push the project config to production the field layout isn't there. It will sync the new block that I created in Vizy and the fields that I have created in Craft but not the field layout for the block. I hope this is clear.

Steps to reproduce

  1. I create the fields I intend to add my new Vizy block on my local machine
  2. Create the new Vizy block and assign a template and create a field layout and assign the fields on my local machine
  3. Push the config files up to production
  4. Check production and the new block is there but not the field layout associated with that block

Additional info

Thanks!

engram-design commented 2 years ago

Can you look in your YAML file for the Vizy field in question? Under settings > fieldData You should have something similar to the following:

columnSuffix: null
contentColumnType: text
fieldGroup: ff0b89f0-0c83-4cd9-8189-d761bbd0c74b # Common
handle: vizyTest
instructions: ''
name: 'Vizy Test'
searchable: false
settings:
  availableTransforms: '*'
  availableVolumes: '*'
  columnType: text
  configSelectionMode: choose
  defaultTransform: ''
  fieldData:
    -
      __assoc__:
        -
          - id
          - group-EsbvKWcxLc
        -
          - name
          - Group
        -
          - blockTypes
          -
            -
              __assoc__:
                0:
                  - id
                  - type-IRBmK5oZVC
                1:
                  - name
                  - 'New Block'
                2:
                  - handle
                  - newBlock
                3:
                  - icon
                  -
                    __assoc__:
                      -
                        - label
                        - 'iOS App Store'
                      -
                        - value
                        - app-store-ios-brands
                5:
                  - enabled
                  - true
                6:
                  - layoutUid
                  - 9851a02b-9f1d-4af5-9ba2-856bb820f47f
                7:
                  - layoutConfig
                  -
                    __assoc__:
                      -
                        - tabs
                        -
                          -
                            __assoc__:
                              -
                                - name
                                - Test
                              -
                                - sortOrder
                                - 1
                              -
                                - elements
                                -
                                  -
                                    __assoc__:
                                      0: [type, craft\fieldlayoutelements\CustomField]
                                      5: [required, false]
                                      6: [width, 100]
                                      7: [fieldUid, 9a2a7bdd-c4db-46f7-a0ad-4c708912eb9f] # Assets

Looking for the layoutUid (mine above is 9851a02b-9f1d-4af5-9ba2-856bb820f47f), that should match up with your local Field Layout that was created. The layoutConfig is also important, as that's what we use to build the field layout on every environment when it needs to be created. If you can share your file that might be easier (and point out the name of the new block you created).

Can you verify if there's a new-ish row in your fieldlayouts database table on production? It might've created the layout, but with the wrong UID.

Otherwise, I may have to introduce some logging here to see what might have gone wrong.

ryguy2407 commented 2 years ago

I went in and manually added the field to the field layout in production (sorry I'm on a bit of a deadline with the client) but interestingly I've since added more fields to the block layout and pushed that to production and it synced the changes as expected. It seems to only happen when I create a new block.

I hope this helps.

          __assoc__:
            -
              - id
              - type-SeakqBSfRd
            -
              - name
              - 'Gated content'
            -
              - handle
              - gatedContent
            -
              - icon
              -
                __assoc__:
                  -
                    - label
                    - Download
                  -
                    - value
                    - download-solid
            -
              - template
              - vizy/_gatedDownload
            -
              - enabled
              - true
            -
              - layoutUid
              - 4a4369c3-0297-45f5-a9ad-ce0fee8e4b0d
            -
              - layoutConfig
              -
                __assoc__:
                  -
                    - tabs
                    -
                      -
                        __assoc__:
                          -
                            - name
                            - CONTENT
                          -
                            - sortOrder
                            - 1
                          -
                            - elements
                            -
                              -
                                __assoc__:
                                  0: [type, craft\fieldlayoutelements\CustomField]
                                  5: [required, false]
                                  6: [width, 100]
                                  7: [fieldUid, eb5c92dc-9532-48c5-89fd-e6aacb772c77] # Form selector
engram-design commented 2 years ago

Hmm, interesting. I've been testing this on a number of environments and it's adding new blocks and their field layouts pretty consistently. I've also tested brand-new Vizy fields, new block type groups, and new block types.

Were they also brand-new fields you added at the same time, or existing fields already applied in the production project config? I'm wondering if it might be an issue where Vizy is trying to use fields for the field layout, but they've yet to be applied first.

ryguy2407 commented 2 years ago

Yeah it was a new field that was added as well. Perhaps that's the key difference because when I added another existing field it synced fine.

engram-design commented 2 years ago

Yeah that seems to be working okay as well, but I'll continue investigating.

ryguy2407 commented 2 years ago

Hmm ok, I've actually had this problem before but I assumed it was something that I did so I didn't lodge an issue, but when it happened again I assumed it must be a bug. Does the order in which I create the fields matter? So if I create the Vizy block and then save it with no fields in the layout and then create the Craft field and go back and add the field to the block? I know it's a bit of long shot but just thought I'd ask...

engram-design commented 2 years ago

I don't think so, and I've also tested both!

engram-design commented 1 year ago

Closing due to age.