`listSearchableFields` for relationship picker?

default discord avatar
see.ess
7 months ago
6

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
    Payload Team
    7 months 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.

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

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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