Autocompletion for a user field at signup

Hey all,

I’ve been playing for a few weeks tweaking the forum. The doc for themes and components has definitely been very helpful!

Lately I’ve added custom user fields at signup that can be edited after signup.
My current challenge is to autocomplete one of these user inputs and connect it to an API.

Right now I’m asking the user to fill the text and store it as a value which is not satisfying.
Besides I have an API that returns a JSON when POSTing the search.
The goal here is to search the input value though the API and autocomplete the values to the user.

I couldn’t find a way to create a new type of custom user field and make it an autocompletion field.
I also got lost trying to create a widget or component and add it to the signup form and saving it’s value to the database.

If you have some clue of a better approach I’ll very much appreciate your help on this one! :slight_smile:

You’d need a plugin to do that. And you could look at some other code that does completion like category for examples of how that works. I’m still bad at that stuff and think it would take me 3-10 hours. I think maybe someone who’s done it before might do it in 1-2.

Hey Jay, indeed that’s what I’m on, writing a plugin.
I do have a theme/component that extends the Discourse and been using extensively the doc to create theme, components and plugins.

However that specific case of customizing a user field remains a puzzler at this stage.
Any help will be highly appreciated.

The place to start is Beginner’s Guide to Creating Discourse Plugins Part 1: Creating a basic plugin. I believe you’ll need to get a good deal further to have a question that is small enough for anyone to offer much advice.

But maybe if you are getting your data for the search externally you could do it all in a theme component. Again, my best advice is to look at places on the discourse core that do the kind of search that you’re talking about, like the category and tag elements.

1 Like