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.

Custom field component to open related collection editor

default discord avatar
big_tiger41242 years ago
4

Hello, Is there any way to add a button in custom field component to open the editor for related collection record?

  • default discord avatar
    simka09972 years ago
    @1093753374450647171

    are the items on the left represent the related docs on the right?

  • default discord avatar
    big_tiger41242 years ago

    yes that's right



    @823927930874363905
  • default discord avatar
    simka09972 years ago

    Since you have the data available already, you should be able to simply trigger the drawer using the

    DrawerToggler

    from

    import { DrawerToggler } from 'payload/components/elements';

    .



    Try something like this:



    <DrawerToggler
      className="btn btn--style-transparent btn--size-small"
      slug={drawerSlug}
    >
      Edit
    </DrawerToggler>


    Rebuild the link of the edit view and use it as the

    drawerSlug

    using probably the

    id

    .



    Btw, this is for Payload V2 not sure about Payload V3.



    You could also check this video:

    https://www.youtube.com/watch?v=B8nNqlREu5o
  • default discord avatar
    big_tiger41242 years ago
    @823927930874363905

    :thumbsupspecial:

    Thanks a lot! This 100% solved my issue.

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.