Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fixed form input name nesting

Jonas Jabari77008c5a0226
diff --git a/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb b/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb
index 505295bb706..288fab4b56e 100644
--- a/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb
+++ b/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb
@@ -48,8 +48,7 @@ class CustomFields::Inputs::Base::Autocomplete::MultiValueInput < ApplicationFor
{
multiple: true,
decorated: decorated?,
- inputId: id,
- inputName: name
+ inputId: id
}
end
diff --git a/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb b/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb
index b533da6f7a9..d14ccd4dac8 100644
--- a/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb
+++ b/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb
@@ -48,8 +48,7 @@ class CustomFields::Inputs::Base::Autocomplete::SingleValueInput < ApplicationFo
{
multiple: false,
decorated: decorated?,
- inputId: id,
- inputName: name
+ inputId: id
}
end
diff --git a/app/forms/custom_fields/inputs/base/utils.rb b/app/forms/custom_fields/inputs/base/utils.rb
index 0f8f1a4dc43..9b5ba930cdd 100644
--- a/app/forms/custom_fields/inputs/base/utils.rb
+++ b/app/forms/custom_fields/inputs/base/utils.rb
@@ -30,7 +30,6 @@ module CustomFields::Inputs::Base::Utils
def base_input_attributes
{
id:,
- scope_name_to_model: false, # TODO: get rid of this, should work with scope_name_to_model: true
name:,
label:,
value:,
@@ -45,8 +44,7 @@ module CustomFields::Inputs::Base::Utils
end
def name
- # TODO: get rid of this, should work with scope_name_to_model: true
- "#{@object.class.name.downcase}[custom_field_values][#{@custom_field.id}]"
+ @custom_field.id.to_s
end
def label
diff --git a/app/forms/custom_fields/inputs/multi_select_list.rb b/app/forms/custom_fields/inputs/multi_select_list.rb
index e71ff69b873..152ce7b0ef3 100644
--- a/app/forms/custom_fields/inputs/multi_select_list.rb
+++ b/app/forms/custom_fields/inputs/multi_select_list.rb
@@ -31,7 +31,11 @@ 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(name: "#{input_attributes[:name]}[]", value:))
+ custom_value_form.hidden(**input_attributes.merge(
+ scope_name_to_model: false,
+ name: "#{@object.class.name.downcase}[custom_field_values][#{input_attributes[:name]}][]",
+ value:
+ ))
custom_value_form.autocompleter(**input_attributes) do |list|
@custom_field.custom_options.each do |custom_option|
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 75ce18ef0ce..d0c3dd82ef6 100644
--- a/app/forms/custom_fields/inputs/multi_version_select_list.rb
+++ b/app/forms/custom_fields/inputs/multi_version_select_list.rb
@@ -31,7 +31,11 @@ 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(name: "#{input_attributes[:name]}[]", value:))
+ custom_value_form.hidden(**input_attributes.merge(
+ scope_name_to_model: false,
+ name: "#{@object.class.name.downcase}[custom_field_values][#{input_attributes[:name]}][]",
+ value:
+ ))
custom_value_form.autocompleter(**input_attributes) do |list|
@object.versions.each do |version|
diff --git a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb
index 6f72a75610a..c183a723f97 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/sections/edit_dialog_component.html.erb
@@ -9,9 +9,7 @@
) do |f|
component_collection do |collection|
collection.with_component(Primer::Alpha::Dialog::Body.new(my: 3, style: "max-height: 500px;")) do
- f.fields_for(:custom_field_values) do |f|
- render(Projects::CustomFields::Form.new(f, project: @project, custom_field_section: @project_custom_field_section))
- end
+ render(Projects::CustomFields::Form.new(f, project: @project, custom_field_section: @project_custom_field_section))
end
collection.with_component(Primer::Alpha::Dialog::Footer.new) do
component_collection do |footer_collection|