How to use TagChooser in a theme component/plugin

I have added a user_custom_field that holds a array of tags. I want to add a TagChooser to the preferences page.

So I put some stuff in a plugin out let and it displays the stuff that’s in the user preferences, so I have the serializer correctly wired up. Hooray.

I have this:

<label class="control-label">{{i18n 'user_tags.preferences.title'}}</label>

{{this.currentUser.user_tags}}

<TagChooser @tags={{this.currentUser.user_tags}} @onChange={{action "changeSelectedTags"}} @everyTag={{true}} @unlimitedTagCount={{true}} @options={{hash
    allowAny=true
  }} />

<div class="desc">{{html-safe this.setting.description}}</div>
<SettingValidationMessage @message={{this.validationMessage}} />

But the TagChooser doesn’t generate any code. I suspect that I need to stick something cryptic in some randomly named file, and after I’m told, it’ll be totally obvious what I needed to put where, but I’ve waded through the Discourse source and a bunch of plugins and am still stuck.

4 Likes

Is it that @tags needs to get an array of tag objects and not just an array of tag names? And rather than throwing some error to point out how silly I am, it just does nothing?

1 Like

Are there any errors in the console? If it’s not generating any HTML, then I’d certainly expect an error in the console :thinking:

3 Likes

Sigh. Well, I swear that it was not generating errors in the console. I swear it.

But now it is. I’ll need to go steal some code for changeSelectedTags from somewhere now. At least I have an idea what to now that I see errors.

Thanks.

3 Likes