プロジェクト

全般

プロフィール

Vote #80723

完了

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

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Custom fields_14
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
14
version_id:
159
issue_org_id:
33085
author_id:
291
assigned_to_id:
332
comments:
6
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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


journals

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

!{border: solid 1px grey; width: 395px;}.Screenshot_2020-03-08.png!
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Setting the target version to 4.0.7.
--------------------------------------------------------------------------------
Committed the patches. Thank you for providing the fix.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが4年以上前に更新

  • カテゴリCustom fields_14 にセット
  • 対象バージョン4.0.7_159 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0