hide id field

default discord avatar
browniedev
10 months ago
14

Hi all 👋



I'm having trouble hiding the id of a collection. I assumed I could do it like this, but I get caught in a loop where it can't log me in properly.



{
  name: 'id',
  type: 'text',
  hidden: true,
},


I can identify at least two potential issues... the

type

is not correct, and/or

hidden

isn't doing what I think it is.



The

hidden

config is defined as

Restrict this field's visibility from all APIs entirely. Will still be saved to the database, but will not appear in any API or the Admin panel.

does

hidden: true

mean that the id is not included in the user object when it is fetched from the database? If this is the case, how do I include the id in the document but hide it from the toggle columns options? (pictured)



Any guidance is appreciated. Thank you

  • discord user avatar
    jmikrut
    Payload Team
    9 months ago

    hey @browniedev — well, the

    id

    will

    be included when fetched from the database—using

    hidden: true

    will simply hide it from being returned from any of Payload's APIs



    we should be able to build in controls to "deactivate" fields from being used as columns, I'd say that is the right way to go here



    because hiding an

    id

    will have unknown side-effects in the admin UI, etc



    we would happily accept a PR for this as well btw



    maybe a new property on a field config like

    admin.disableColumn

    or similar



    and then simply check for that property when we expose what columns are available to use in the List view



    could be a good first contribution if you're up for it 😈

  • default discord avatar
    browniedev
    9 months ago

    Yes!! When I get home today, I'll follow up on this 💯

  • discord user avatar
    jmikrut
    Payload Team
    9 months ago
    https://github.com/payloadcms/payload/discussions/1219


    this might be helpful if you end up deciding to PR

  • default discord avatar
    browniedev
    9 months ago

    I'm open to the idea of making a contribution, do you have any documentation on the process of contributing?

  • discord user avatar
    jmikrut
    Payload Team
    9 months ago
    https://github.com/payloadcms/payload/blob/master/contributing.md


    this plus the Discussion above should be helpful

  • default discord avatar
    TheFrontend
    7 months ago

    @browniedev have you tried to implement this? Would be nice to have!

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.