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.

`listSearchableFields` for relationship picker?

default discord avatar
see.ess2 years ago
1

Does anyone know of a way that you can search by a field other than the title when selecting a record from a relationship field select dropdown?



In my example, I want to associate related "Fixtures" to one another, but I'd like the ability to search not only by the

title

, but also by the

partNumber

field. I can make this happen on the collection list page (by way of

listSearchableFields

in my collection declaration, but this doesn't seem to carry over to the select dropdown.



Any ideas?





  • discord user avatar
    dribbens
    2 years ago

    Currently that is not possible. This would be a great feature to add.



    I would make it so that the relationship field has an

    admin

    property called

    searchField

    or similar that would take the path of the thing to search on.



    Then the relationship field input could use that instead of the

    useAstitle

    field when the config option is present.



    One thing that complexifies this a bit is that having multiple

    relationTo

    for different collection would need their own search fields. That leaves a lot of room for error, so maybe better to have it on the collection as a sibling to

    listSearchableFields

    . I'm thinking out loud.


    The next step is to create a Github discussion for a new feature request where these details are figured out and somebody can go on to code it.

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.