diff --git a/app/helpers/dynamic_form_helper.rb b/app/helpers/dynamic_form_helper.rb index 1c72763..a7f217e 100644 --- a/app/helpers/dynamic_form_helper.rb +++ b/app/helpers/dynamic_form_helper.rb @@ -110,7 +110,7 @@ } end - def create_select_field(form, value, name, label, select_values, validation: nil, html_class: nil, readonly: false) + def create_select_field(form, value, name, label, select_values, validation: nil, html_class: nil, readonly: false, multiple: false, ttip: nil) render partial: 'shared/dynamic_form/fields/select_field', locals: { f: form, @@ -119,8 +119,10 @@ field_label: label, select_values: select_values, field_class: html_class, + multiple: multiple, readonly: readonly, - validation: validation + validation: validation, + ttip: ttip } end diff --git a/app/views/branded/shared/dynamic_form/_form.html.erb b/app/views/branded/shared/dynamic_form/_form.html.erb index 3839bb5..d79eda1 100644 --- a/app/views/branded/shared/dynamic_form/_form.html.erb +++ b/app/views/branded/shared/dynamic_form/_form.html.erb @@ -20,7 +20,7 @@ <% when 'string' %> <% if prop['inputType'].present? %> <% if prop['inputType'] == 'dropdown' && dropdownValues %> - <%= create_select_field(f, value, "#{f.object_name}[#{field_name}]", label, dropdownValues, readonly: readonly, validation: validation) %> + <%= create_select_field(f, value, "#{f.object_name}[#{field_name}]", label, dropdownValues, readonly: readonly, validation: validation, ttip: ttip) %> <% end %> <% elsif prop['format'].nil?%> <%= create_text_field(f, value, field_name, label, readonly: readonly, validation: validation, ttip: ttip, example: example) %> @@ -36,6 +36,7 @@ <% when 'boolean' %> <%= create_checkbox_field(f, value, field_name, label, readonly: readonly, validation: validation) %> <% when 'array' %> + <%# List of linked fragments displayed as table. Linked fragments are edited through a modal %> <% if prop['items']['type'] == 'object' && prop['items']['schema_id'].present? %> <% unless classname == "research_output" %> <% sub_schema = sub_schemas[prop['items']['schema_id']] %> @@ -50,16 +51,22 @@ ) %> <% end %> <% else %> - <%= render(partial: 'shared/dynamic_form/fields/simple_multiple_field', locals: { - f: f, - field_values: value, - readonly: readonly, - field_label: label, - field_properties: prop['items'], - field_name: field_name, answer_id: nil, - ttip: ttip - } - ) %> + <%# Select 'multiple' where the user can choose multiple options %> + <% if prop['inputType'] == 'dropdown' && dropdownValues %> + <%= create_select_field(f, value, "#{f.object_name}[#{field_name}]", label, dropdownValues, readonly: readonly, multiple: true, validation: validation, ttip: ttip) %> + <% else %> + <%# Input field associated with 'Add' and 'Delete' icons %> + <%= render(partial: 'shared/dynamic_form/fields/simple_multiple_field', locals: { + f: f, + field_values: value, + readonly: readonly, + field_label: label, + field_properties: prop['items'], + field_name: field_name, answer_id: nil, + ttip: ttip + } + ) %> + <% end %> <% end %> <% when 'object' %> <% if prop["schema_id"].present? %> diff --git a/app/views/branded/shared/dynamic_form/fields/_select_field.html.erb b/app/views/branded/shared/dynamic_form/fields/_select_field.html.erb index 20dd26d..ca4b30a 100644 --- a/app/views/branded/shared/dynamic_form/fields/_select_field.html.erb +++ b/app/views/branded/shared/dynamic_form/fields/_select_field.html.erb @@ -1,4 +1,4 @@ -<%# locals: { f, field_label, field_name, select_values, selected_value, field_class, readonly, validation } %> +<%# locals: { f, field_label, field_name, select_values, selected_value, field_class, readonly, multiple, validation, ttip } %> <% field_label = field_label || 'No label defined' %>