Exclude UI typed Field from Sorting/ Editing

default discord avatar
Chris_Heinz
5 months ago
4

I used the field type "ui" for inserting a small button to link to the page that is currently edited. Unfortunately this field also appears in the sorting or editing context although it is empty. Is there a way to tell payload no ignore the field also for the database?

  • default discord avatar
    Jarrod
    5 months ago

    Our form hooks should be all you need to do this inside of your custom UI component 🙂



    https://payloadcms.com/docs/admin/hooks
  • default discord avatar
    Chris_Heinz
    5 months ago

    Somehow I could not find a solution to this even with the provided documentation. Isn't including fields of type UI within edit and column context unwanted behaviour anyway ? As it says in the docs "It has absolutely no effect on the data of your documents. It is presentational-only." As the value for presentational fields is supposed to be empty anyway it does not make sense to display it or edit it. @Jarrod

    Bildschirmfoto_2023-04-14_um_11.16.23.png
  • default discord avatar
    Jarrod
    5 months ago

    I don't think it is unwanted behavior, what if you wanted to render a button that takes you to the page (like you have right there). You just need to render a custom Cell component for your ui field, read about it here:

    https://payloadcms.com/docs/admin/components#cell-component
  • default discord avatar
    Chris_Heinz
    5 months ago

    Got you. I didn't wanted to have the Cell functionality in the first place but now I can make sense out of it showing the link again. Thanks for you patience!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.