access restriction on relationship field

default discord avatar
5 months ago

I have set up isAdmin and isAdminField permissions which works fine. However, I would like to set up categories so that it is only possible to select pre-existing categories, disallowing to create new categories if not admin. So if the role is editor (e.g. not admin), then only selecting existing categories in the category relationship field should be possible.

I have already tried with:

access: {

create: access.isAdminFieldLevel,

update: access.isAdminFieldLevel,


but the problem is that with this restriction the entire field becomes un-editable, so selecting existing categories wont work. Any suggestions on how to solve this?

Found the solution: I have to move the access control directly to the category collection and set the access so that admin is the only one that can write changes.

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


    Connect with the Payload Community on Discord



    Can't find what you're looking for?

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