Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutocompleteInput and ReferenceInput search in 'q' #2615

Closed
gmcadosch opened this issue Dec 3, 2018 · 4 comments
Closed

AutocompleteInput and ReferenceInput search in 'q' #2615

gmcadosch opened this issue Dec 3, 2018 · 4 comments

Comments

@gmcadosch
Copy link

gmcadosch commented Dec 3, 2018

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
@kctrlv
Copy link

kctrlv commented Dec 3, 2018

You need to pass filterToQuery function prop into ReferenceInput

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

@fzaninotto
Copy link
Member

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

@gmcadosch
Copy link
Author

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.

@developerium
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants