プロジェクト

全般

プロフィール

Vote #75850

完了

Custom field is rendered, even if its value is empty (for multiple)

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

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

0%

予定工数:
category_id:
14
version_id:
80
issue_org_id:
18654
author_id:
16879
assigned_to_id:
1
comments:
3
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
81
ステータス-->[Closed]

説明

Redmine checks, if the value is available for the custom field, as follows:


if custom_value.value.present?

But for multiple custom fields (e.g., lists, that allow selecting multiple values), the original @nil@ value is replaced with @[nil]@ (not sure where exactly). So, @[nil].empty?@ returns @false@ and the custom field gets rendered.

This issue affects 3.0.x and 1.4.x versions of Redmine.

P.S. Can be solved by montkey-patching CustomFieldValue as follows:


alias_method_chain :value, :extended

...

def value_with_extended
    value = value_without_extended
    if custom_field.multiple? && value.present? && value.size == 1 && value.first.nil?
        nil
    else
        value
    end
end

journals

--------------------------------------------------------------------------------
Fixed in r13864, thanks for pointing this out.
--------------------------------------------------------------------------------

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


related_issues

relates,Closed,19482,Custom field (long text format) displayed even if empty

Admin Redmine さんが約4年前に更新

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

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

いいね!0
いいね!0