Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Publishing clears relationship fields

default discord avatar
zoul08132 years ago
6

I've upgraded to 1.15.4 (ran migration, enabled queryDraft_2_0)


After the upgrade, it seems that Publish Changes is clearing two of my relationship fields ('tags' and 'products') when the editor refreshes. The content is properly published, but these fields are cleared on admin update. If I refresh the admin, the fields are correctly populated. If I edit the document more, and try to publish while these fields are cleared I get the error "field has the following invalid selections: [object Object]: 0"



I've rolled back to 1.15.3 and the problem is resolved - this appears to be related to the changes made here:

https://github.com/payloadcms/payload/commit/5096c378743f4c5eb5f4f2f7e67e5e206cc9da40
  • default discord avatar
    integra96572 years ago

    I have the same problem only with hasMany relations after saving more than once without leaving the page. Noticed first in 1.6.9 and the problem still happens in 1.15.2/3/4 with new db.

  • default discord avatar
    zoul08132 years ago

    it looks like the update in 1.15.4 doesn't account for arrays when setting the values of the relationship - I don't know enough to open a PR to fix it ...

  • default discord avatar
    integra96572 years ago
  • discord user avatar
    jarrod_not_jared
    2 years ago

    Yep I can fix, thank you all for reporting!



    Definitely by EOD Monday, possibly before bc it saddens me



    PR to fix this has been opened:

    https://github.com/payloadcms/payload/pull/3300
  • default discord avatar
    zoul08132 years ago
    @281120856527077378

    thanks - ETA for when this will make it into a release?

  • discord user avatar
    jarrod_not_jared
    2 years ago
    @131800639293358080

    Just released!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.