Defect #33085

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

Added by Thomas Löber about 1 month ago. Updated 14 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Custom fields
Target version:4.0.7
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

Screenshot_2020-03-08.png (31.6 KB) Go MAEDA, 2020-03-08 00:04

add_test.patch Magnifier (1.18 KB) Mizuki ISHIKAWA, 2020-03-09 06:40

Associated revisions

Revision 19588
Added by Go MAEDA 14 days ago

Fix that unable to update the values of a custom field for time tracking activities when multiple values option is enabled (#33085).

Patch by Thomas Löber.

Revision 19589
Added by Go MAEDA 14 days ago

Test for r19588 (#33085).

Patch by Mizuki ISHIKAWA.

Revision 19590
Added by Go MAEDA 14 days ago

Merged r19588 and r19589 from trunk to 4.1-stable (#33085).

Revision 19591
Added by Go MAEDA 14 days ago

Merged r19588 and r19589 from trunk to 4.0-stable (#33085).

History

#1 Updated by Go MAEDA 26 days ago

I have confirmed that values for a custom field of time tracking activities cannot be saved if "Multiple values" option is enabled.

#2 Updated by Mizuki ISHIKAWA 25 days ago

Thomas Löber wrote:

Here is a patch to fix this issue:

[...]

I have confirmed that the code you wrote in descriptipn solves this problem.
To permit an array value of strong_parameters, it is necessary to set an empty array, so {c.id.to_s => []} is set when c.multiple? is true.

The attached patch adds a test to the code written by Thomas Löber.

#3 Updated by Go MAEDA 25 days ago

  • Target version set to Candidate for next minor release

#4 Updated by Go MAEDA 24 days ago

  • Target version changed from Candidate for next minor release to 4.0.7

Setting the target version to 4.0.7.

#5 Updated by Go MAEDA 14 days ago

  • Subject changed from Cannot use custom fields with multiple values in enumerations to Unable to update the values of a custom field for enumerations when multiple values option is enabled
  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patches. Thank you for providing the fix.

#6 Updated by Go MAEDA 14 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF