diff --git a/app/dictionaries/keywords_dictionary.rb b/app/dictionaries/keywords_dictionary.rb
new file mode 100644
index 000000000..0bb8e372a
--- /dev/null
+++ b/app/dictionaries/keywords_dictionary.rb
@@ -0,0 +1,12 @@
+# Dictionary of Keywords
+class KeywordsDictionary < Dictionary
+
+ DEFAULT_FILE = 'keywords.yml'
+
+ private
+
+ def dictionary_filepath
+ get_file_path 'keywords', DEFAULT_FILE
+ end
+
+end
\ No newline at end of file
diff --git a/app/views/common/_dropdown.html.erb b/app/views/common/_dropdown.html.erb
index fb5401501..6c61cdfa2 100644
--- a/app/views/common/_dropdown.html.erb
+++ b/app/views/common/_dropdown.html.erb
@@ -25,13 +25,6 @@ render :partial => 'common/dropdown',
options ||= format_for_dropdown(field_name.capitalize.constantize.all)
existing ||= format_for_dropdown(resource.send(field_name.pluralize))
- # Remove existing objects from the pool of options
- options = options - existing
- dropdown_toggle_button_name ||= ''
- if dropdown_toggle_button_name.blank?
- dropdown_toggle_button_name = "Add #{field_name.to_s.sub(/_ids?\z/, '').humanize}"
- end
-
# show the required label?
required ||= false
@@ -43,6 +36,14 @@ render :partial => 'common/dropdown',
# check title
title ||= ''
+
+ # Remove existing objects from the pool of options
+ options = options - existing
+ dropdown_toggle_button_name ||= ''
+ if dropdown_toggle_button_name.blank?
+ dropdown_toggle_button_name = "Add #{field_label.to_s.sub(/_ids?\z/, '').humanize}"
+ end
+
%>
diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb
index b74a07d25..b2f309379 100644
--- a/app/views/events/_form.html.erb
+++ b/app/views/events/_form.html.erb
@@ -90,8 +90,16 @@
title: t('events.hints.hosts') %>
- <%= f.multi_input :keywords, errors: @event.errors[:keywords],
- title: t('events.hints.keywords') %>
+ <% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
+ <%= f.dropdown :keywords,
+ options: KeywordsDictionary.instance.options_for_select,
+ label: t('activerecord.attributes.event.keywords'),
+ errors: @event.errors[:keywords],
+ title: t('events.hints.keywords') %>
+ <% else %>
+ <%= f.multi_input :keywords, errors: @event.errors[:keywords],
+ title: t('events.hints.keywords') %>
+ <% end %>
<% if !TeSS::Config.feature['disabled'].include? 'ardc_fields_of_research' %>
diff --git a/app/views/materials/_form.html.erb b/app/views/materials/_form.html.erb
index 22eb23b4e..0c901d641 100644
--- a/app/views/materials/_form.html.erb
+++ b/app/views/materials/_form.html.erb
@@ -37,7 +37,16 @@
- <%= f.multi_input :keywords, title: t('materials.hints.keywords'), visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
+ <% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
+ <%= f.dropdown :keywords,
+ options: KeywordsDictionary.instance.options_for_select,
+ label: t('activerecord.attributes.event.keywords'),
+ errors: @material.errors[:keywords],
+ title: t('events.hints.keywords'),
+ visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
+ <% else %>
+ <%= f.multi_input :keywords, title: t('materials.hints.keywords'), visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
+ <% end %>
<%= f.input :licence, collection: licence_options_for_select, as: :grouped_select, group_method: :last, group_label_method: :first,
diff --git a/config/dictionaries/keywords.yml b/config/dictionaries/keywords.yml
new file mode 100644
index 000000000..28bbf0586
--- /dev/null
+++ b/config/dictionaries/keywords.yml
@@ -0,0 +1,3 @@
+placeholder:
+ title: placeholder
+ description: 'Placeholder'
diff --git a/config/tess.example.yml b/config/tess.example.yml
index 70560649e..a3c642f48 100644
--- a/config/tess.example.yml
+++ b/config/tess.example.yml
@@ -168,7 +168,7 @@ default: &default
bioschemas_testing: false
collection_curation: true
auto_parse_vars: [] # available features to auto parse from description: ['keywords', 'target_audience']
- controlled_vocabulary_vars: [] # available features: ['target_audience']
+ controlled_vocabulary_vars: [] # available features: ['keywords', 'target_audience']
# User login
invitation: false