Feature(s) impacted
Using the Dropdown Widget, with dynamic data in simple mode and with the searchable mode - will actually search by the field the drop down users AND the “reference field” of the target collection.
BUT it would not show the values even if documents are found if they are not from the dropdown configured field.
Observed behavior
Only if the searched value is from the field used by the dropdown - results are shown.
Here is a detailed example.
Assume collection named makers
that has the fields name
and id
.
Assume a field called makerId
on some entity - that is configured to lookup “makers” from the above collection.
To do that we define the widget so:
Edit Widget - Dropdown (Type - Dynamic, Values - Simple, Collection - makers
, field - id
)
“Enable Search” is true.
The makers
collection is configured to use the name
field as the value shown when referenced.
Now, when the user types into the makerId
field to lookup makers - the system would issue the following search (mongodb here):
makers.aggregate([ { '$match': { '$and': [ { '$or': [ { name: /.*erik.*/i }, { id: /.*erik.*/i } ] } ] } }, { '$skip': 0 }, { '$limit': 100 }], {})
As you see, makers with names like erik
are found - and indeed returned from the API to the forest app. BUT the widget dropdown will not show those results - since the id
of all those makers does not match the erik
string (presumably)
Again - actual results from the API do include makers here - so I must assume the widget locally has a matching (simple search) against the list of id
s the API returned to further narrow down the list of options displayed.
Expected behavior
Results (id
values in the above scenario) are shown for any match on the searched value.
Context
forest-express-mongoose@7.6.0
forest-express@8.4.0