Project

General

Profile

Actions

Defect #33085

closed

Unable to update the values of a custom field for enumerations when multiple values option is enabled

Added by Thomas Löber almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Custom fields
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Hi,

When I add a custom field to an enumeration and the custom field has the "Multiple values" option set, it is not possible to change the custom value when editing the enumeration.

This is because with multiple values the POST parameter is an array, but that is not permitted in the EnumerationsController.

Here is a patch to fix this issue:

   def enumeration_params
     # can't require enumeration on #new action
-    cf_ids = @enumeration.available_custom_fields.map{|c| c.id.to_s}
+    cf_ids = @enumeration.available_custom_fields.map{|c| c.multiple? ? {c.id.to_s => []} : c.id.to_s}
     params.permit(:enumeration => [:name, :active, :is_default, :position, :custom_field_values => cf_ids])[:enumeration]
   end
 end

Best regards,
Thomas


Files

Screenshot_2020-03-08.png (31.6 KB) Screenshot_2020-03-08.png Go MAEDA, 2020-03-08 00:04
add_test.patch (1.18 KB) add_test.patch Mizuki ISHIKAWA, 2020-03-09 06:40
Actions

Also available in: Atom PDF