Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: add multiselect user custom field (#13560)

Krzysztof Kotlareka69839689da8
diff --git a/app/assets/javascripts/admin/addon/models/user-field.js b/app/assets/javascripts/admin/addon/models/user-field.js
index 495be7a08d0..53b92a63fd9 100644
--- a/app/assets/javascripts/admin/addon/models/user-field.js
+++ b/app/assets/javascripts/admin/addon/models/user-field.js
@@ -15,6 +15,7 @@ UserField.reopenClass({
UserFieldType.create({ id: "text" }),
UserFieldType.create({ id: "confirm" }),
UserFieldType.create({ id: "dropdown", hasOptions: true }),
+ UserFieldType.create({ id: "multiselect", hasOptions: true }),
];
}
diff --git a/app/assets/javascripts/discourse/app/templates/components/user-fields/multiselect.hbs b/app/assets/javascripts/discourse/app/templates/components/user-fields/multiselect.hbs
new file mode 100644
index 00000000000..f81fa36fd43
--- /dev/null
+++ b/app/assets/javascripts/discourse/app/templates/components/user-fields/multiselect.hbs
@@ -0,0 +1,19 @@
+<label class="control-label" for={{concat "user-" this.elementId}}>
+ {{html-safe this.field.name}}
+ {{#if this.field.required}}
+ <span class="required">*</span>
+ {{/if}}
+</label>
+
+<div class="controls">
+ {{multi-select
+ id=(concat "user-" this.elementId)
+ content=this.field.options
+ valueProperty=null
+ nameProperty=null
+ value=this.value
+ none=this.noneLabel
+ onChange=(action (mut this.value))
+ }}
+ <div class="instructions">{{html-safe this.field.description}}</div>
+</div>
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 7b2b26969db..6d3f72afabd 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -5095,6 +5095,7 @@ en:
text: "Text Field"
confirm: "Confirmation"
dropdown: "Dropdown"
+ multiselect: "Multiselect"
site_text:
description: "You can customize any of the text on your forum. Please start by searching below:"