From 857382b6d923c2c06b6e4c656790122aa79efda2 Mon Sep 17 00:00:00 2001 From: Klaus Zanders Date: Fri, 29 Nov 2024 14:58:53 +0100 Subject: [PATCH] fix generating input field names correctly for names with camelized names --- app/forms/custom_fields/inputs/multi_select_list.rb | 10 ++++++---- .../custom_fields/inputs/multi_user_select_list.rb | 7 ++++--- .../custom_fields/inputs/multi_version_select_list.rb | 10 ++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/forms/custom_fields/inputs/multi_select_list.rb b/app/forms/custom_fields/inputs/multi_select_list.rb index 832ddb524b49..85434337830a 100644 --- a/app/forms/custom_fields/inputs/multi_select_list.rb +++ b/app/forms/custom_fields/inputs/multi_select_list.rb @@ -31,16 +31,18 @@ class CustomFields::Inputs::MultiSelectList < CustomFields::Inputs::Base::Autoco # autocompleter does not set key with blank value if nothing is selected or input is cleared # in order to let acts_as_customizable handle the clearing of the value, we need to set the value to blank via a hidden field # which sends blank if autocompleter is cleared - custom_value_form.hidden(**input_attributes.merge( + custom_value_form.hidden( + **input_attributes, scope_name_to_model: false, - name: "#{@object.class.name.downcase}[custom_field_values][#{input_attributes[:name]}][]", + name: "#{@object.model_name.element}[custom_field_values][#{input_attributes[:name]}][]", value: - )) + ) custom_value_form.autocompleter(**input_attributes) do |list| @custom_field.custom_options.each do |custom_option| list.option( - label: custom_option.value, value: custom_option.id, + label: custom_option.value, + value: custom_option.id, selected: selected?(custom_option) ) end diff --git a/app/forms/custom_fields/inputs/multi_user_select_list.rb b/app/forms/custom_fields/inputs/multi_user_select_list.rb index f086b8b8948e..dfc7e691dd8f 100644 --- a/app/forms/custom_fields/inputs/multi_user_select_list.rb +++ b/app/forms/custom_fields/inputs/multi_user_select_list.rb @@ -33,11 +33,12 @@ class CustomFields::Inputs::MultiUserSelectList < CustomFields::Inputs::Base::Au # autocompleter does not set key with blank value if nothing is selected or input is cleared # in order to let acts_as_customizable handle the clearing of the value, we need to set the value to blank via a hidden field # which sends blank if autocompleter is cleared - custom_value_form.hidden(**input_attributes.merge( + custom_value_form.hidden( + **input_attributes, scope_name_to_model: false, - name: "#{@object.class.name.downcase}[custom_field_values][#{input_attributes[:name]}][]", + name: "#{@object.model_name.element}[custom_field_values][#{input_attributes[:name]}][]", value: - )) + ) custom_value_form.autocompleter(**input_attributes) end diff --git a/app/forms/custom_fields/inputs/multi_version_select_list.rb b/app/forms/custom_fields/inputs/multi_version_select_list.rb index f03ce7672f6c..2740a117e840 100644 --- a/app/forms/custom_fields/inputs/multi_version_select_list.rb +++ b/app/forms/custom_fields/inputs/multi_version_select_list.rb @@ -35,16 +35,18 @@ class CustomFields::Inputs::MultiVersionSelectList < CustomFields::Inputs::Base: # autocompleter does not set key with blank value if nothing is selected or input is cleared # in order to let acts_as_customizable handle the clearing of the value, we need to set the value to blank via a hidden field # which sends blank if autocompleter is cleared - custom_value_form.hidden(**input_attributes.merge( + custom_value_form.hidden( + **input_attributes, scope_name_to_model: false, - name: "#{@object.class.name.downcase}[custom_field_values][#{input_attributes[:name]}][]", + name: "#{@object.model_name.element}[custom_field_values][#{input_attributes[:name]}][]", value: - )) + ) custom_value_form.autocompleter(**input_attributes) do |list| assignable_custom_field_values(@custom_field).each do |version| list.option( - label: version.name, value: version.id, + label: version.name, + value: version.id, selected: selected?(version) ) end