Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dave Wize's avatar

Nova searchable field with subtitles?

I have a nova belongsTo field with a searchable method on it, but it only displays the name and not the address, which is necessary since the name is not unique.

Is there any way I can customize the search field's display data?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

Yes, you can customize the display data of a searchable field in Nova by using the displayUsing method. Here's an example:

BelongsTo::make('User')
    ->searchable()
    ->displayUsing(function ($user) {
        return $user->name . ' - ' . $user->address;
    });

In this example, we're using the displayUsing method to define a custom display format for the User field. The function passed to displayUsing takes the related model as its argument, and returns a string that will be displayed in the search results.

In this case, we're concatenating the user's name and address with a hyphen separator. You can customize this format to suit your needs.

With this code, when you search for a user, the search results will display the name and address together, making it easier to identify the correct user.

Please or to participate in this conversation.