mikebronner / nova-prepopulate-searchable

A tool to allow BelongsTo searchable fields to be pre-populated with data
MIT License
37 stars 21 forks source link

How to add where clause on query for prepopulate() #15

Closed saqueib closed 4 years ago

saqueib commented 5 years ago

Hi Alex, Please share how do I pass a query to repopulate the search field.

You may optionally pass through a search query to the prepopulate method, and the keywords passed will be used for the search initially, before resetting the search to being empty (as it currently is).

Above expiation is not clear for me. If you can give some code sample on how to use it that will be great.

I want to load only active users.

baldhadhaval08 commented 4 years ago

@saqueib If you have found a way to pass a query to repopulate then can you please share it here?

mikebronner commented 4 years ago

@saqueib @baldhadhaval08 would you guys mind testing version 1.2.0 and let me know if that fixes things for you? Thanks!

mikebronner commented 4 years ago

You can pass in a string to the prepopulate method, which basically simulates typing in a search string:

    BelongsTo::make("Archive")
        ->searchable()
        ->prepopulate("test"),

This example would only pre-populate the items containing "test" in their display-field.