Conditional Admin Descriptions

default discord avatar
theduncolast year

Is it possible to make a conditional admin description? Looking at the


types, it looks like it can be passed a React component, but none of the types seem to pass along


to the function/component which I would need to do this. Is there a way to create a React component that knows about the current


state of the form and can change the description text based on that?

I am aware that the pattern I've chosen that created this problem isn't a great one, but I'm locked in now so I'd like a way to do this.

  • default discord avatar
    notchrlast year

    @thedunco What about having a custom field type that acts as a description. Then conditions would be able to show/hide that

  • default discord avatar
    theduncolast year

    Oh I suppose that could work as well. And then use the React hooks and/or props if they get passed in to get the


    info I need?

    I have "solved" this in my case by just having the description worded differently, so it's not a huge deal, but I feel like pretty much everything in the config should be able to accept a function that has access to



  • default discord avatar
    notchrlast year

    Yeah agreed! I'm not sure about the hooks part, but it sounds like it should work?

    I almost always use the siblingData versus data, as a side note

  • discord user avatar
    last year


    one thing we could do is pass the


    component the


    of the field

    that way, you could use the form methods to retrieve


    we would not want to just pass in


    itself, because we don't want to retrieve that unless we HAVE to

    so i'd leave that to your custom component to leverage hooks to retrieve (which you could as long as you had the path)

    @thedunco sounds like a good PR to make

    what you'd wanna do is:

    1. modify the props of our built-in


    component to require the passing of


    2. locate all instances of


    and update it so that you pass the


    into it

    3. update the


    type to take a


    in addition to the


    that it takes now

    4. update docs of course

  • default discord avatar
    theduncolast year

    Yeah, maybe I'll have some time this weekend to give this a shot!

Star on GitHub


Chat on Discord



Can't find what you're looking for?

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