payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
23.34k stars 1.49k forks source link

Block > tab > collapsible> field is not storing any data #976

Closed matthijs166 closed 2 years ago

matthijs166 commented 2 years ago

Bug Report

When Im saving the page and have data in the field Block > tab > collapsible > field the data is not stored

Expected Behavior

I expect that it saves the field

Current Behavior

Fields stays empty

Possible Solution

Steps to Reproduce

Field configuration:

{"slug":"quoteBanner","imageURL":"/media/block-previews/quote-banner.png","fields":[{"type":"tabs","tabs":[{"label":"Content","fields":[{"name":"sectionBorderColor","label":"Sectie rand kleur","type":"text","required":true,"defaultValue":"orange","admin":{"components":{}}},{"name":"quote","label":"Quote","type":"textarea","defaultValue":"Eigenlijk waren we helemaal super tevreden op het bezoek van NVT."},{"type":"collapsible","label":"Knop","fields":[{"name":"button","label":"Knop","type":"group","fields":[{"type":"text","name":"text","label":"Tekst","required":true,"defaultValue":"Bekijken"},{"type":"relationship","name":"link","label":"Link","relationTo":"pages","maxDepth":1},{"name":"color","label":"Kleur","type":"text","required":true,"defaultValue":"orange","admin":{"components":{}}},{"type":"select","name":"iconType","label":"Icon Type","defaultValue":"empty","options":[{"value":"empty","label":"Geen icon"},{"value":"customer-support","label":"Customer support"},{"value":"home","label":"Home"},{"value":"user","label":"User"}]}]}]}]},{"label":"Algemeen","fields":[{"name":"right","label":"Rechts uitgelijnd","type":"checkbox","defaultValue":true},{"name":"bgImage","label":"Achtergrond afbeelding","relationTo":"media","type":"upload","required":true}]}]}]}

Detailed Description

"payload": "^1.0.24",

DanRibbens commented 2 years ago

Thanks for reporting this!

I was able to reproduce it and it looks a problem with the frontend. The data sending from the create form in my test looks like this:

{
   "blocks":[
      {
         "0":{
            "textInCollapsible":"gtest"
         },
         "id":"6308312cc6c9720dbcb66888",
         "blockType":"tabs"
      },
      {
         "id":"63083133c6c9720dbcb66889",
         "text":"test",
         "blockType":"text"
      }
   ]
}

This is based on the block set up here: https://github.com/payloadcms/payload/blob/fix/%23976-field-not-storing-data/test/fields/collections/Blocks/index.ts#L70

The extra keyed object "0" is causing the data to not match up with the schema.

Reproduced in branch fix/#976-field-not-storing-data.

github-actions[bot] commented 1 week ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.