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.

Make field `readOnly` conditionally

default discord avatar
nikich2 years ago
3

Is it possible to do so as we can hide/show field based on siblingData? I would like to make it possible to fill text field only once, this means you are not allowed to edit it once collection/global was saved.

  • default discord avatar
    hades2000822 years ago

    If you set the "update" permissions on the field to

    false

    and leave create & read as

    true

    then it can be set at creation and read anytime but cannot be updated after creation.



    See:

    https://payloadcms.com/docs/access-control/fields
  • default discord avatar
    nikich2 years ago
    @365498720726286349

    A bit unintuitive but works like a charm, thanks!

  • default discord avatar
    hades2000822 years ago

    It's more powerful this way as you might want to set it to allow certain roles to be able to update it (like CEO or admins) but not others.

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.