React-admin: AutocompleteInput and ReferenceInput search in 'q'

Created on 3 Dec 2018  路  4Comments  路  Source: marmelab/react-admin

What you were expecting:
The AutocompleteInput component should send a request for searching the field defined as OptionName to the data provider.

What happened instead:
The AutocompleteInput component sends a request to search in field "q" to the data provider:
http://localhost:3000/code_country?order=id.desc&q=ilike.%2A%2A
which generates the error "column code_country.q does not exist".

Steps to reproduce:
Example:

<ReferenceInput label="resources.address.fields.country" source="country_id" reference="code_country">
  <AutocompleteInput optionText="name" optionValue="id" />
</ReferenceInput>

Environment

  • React-admin version: 2.4.4

Most helpful comment

You need to pass filterToQuery function prop into ReferenceInput

In your case filterToQuery={searchText => ({ name: searchText })}>

All 4 comments

You need to pass filterToQuery function prop into ReferenceInput

In your case filterToQuery={searchText => ({ name: searchText })}>

yep, as @kctrlv said, it's not a bug, it's a feature!

Thanks for this, it helped. But wouldn't it be better to disable this behaviour per default as it needs a special implementation of the data provider? Anyway, I'm happy now.

I think this "feature" is kind of a hidden feature, I had to dig through the issues to find it :sweat_smile:

Was this page helpful?
0 / 5 - 0 ratings