Skip to content

Commit

Permalink
fix generating input field names correctly for names with camelized n…
Browse files Browse the repository at this point in the history
…ames
  • Loading branch information
klaustopher committed Dec 3, 2024
1 parent 5b70f7e commit 857382b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
10 changes: 6 additions & 4 deletions app/forms/custom_fields/inputs/multi_select_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions app/forms/custom_fields/inputs/multi_user_select_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions app/forms/custom_fields/inputs/multi_version_select_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 857382b

Please sign in to comment.