Hello,
I’m completely new to wappler and I have a difficulty combining different fields in an autocomplete text input.
So, for example I have 2 tables of ‘cars’ and ‘bikes’ (both have fields of ‘id’ and ‘brand’). How do I have both in the autocomplete so the user can get suggestions for cars and bikes by typing the brand?
If what you mean is the views folder in the database manager, right-clicking on it does not give me an option to create any. maybe because I’m using docker and node.js?
thanks for the suggestion! However I haven’t managed to get it to work because I actually have different field names and I’m not familiar with too many syntax yet.
let’s say instead of ‘brand’, I have ‘car_brand’ and ‘bike_brand’, how do I write it then?
You can’t use autocomplete with 2 different database tables. You need to join them in the query builder OR create a view in your database and use it in the query builder.
Teodor's right. I missed the part about the two fields being in separate tables.
Once you have a query that returns both fields, then my syntax would work.
To explain it clearer, I want to replicate doctolib.de where the input box does not only return the autocomplete for health problems but also the doctors' specialty and their names.
For the first one, I saw your guide on joining:
But I think it combines 2 entries into 1, instead of appending the list (hopefully I'm mistaken).
And for the second method, If what you mean is the views folder in database manager, I don't see any option to create a 'view'. just to collapse and expand all. maybe due to docker + node.js setup? I don't really know
You can’t create views in the database manager. You need to create them on database level. Or use joins, so join your two tables in the query manager and use the syntax Sid already posted.
so after joining both tables, I now have fields of ‘id’, ‘car_brand’ and ‘bike_brand’.
On the autocomplete input, I set the data source to the join value but now I’m stuck on the text field and value field
That is not as simple as it might sound to you.
You will need a custom query here for what you need to achieve. For example using UNION will do what you need:
SELECT car_brands FROM table_cars
UNION ALL
SELECT bike_brands FROM table_bikes
make sure to replace the table columns and table names as they are in your database.